mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
fixed version check to work even without internet
This commit is contained in:
parent
5eaa4b1e8b
commit
3990b182e8
@ -3,6 +3,9 @@ import json.decoder
|
|||||||
import requests
|
import requests
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
|
from socket import gaierror
|
||||||
|
from urllib3.exceptions import MaxRetryError
|
||||||
|
|
||||||
analytics_url = 'https://api.gradio.app/'
|
analytics_url = 'https://api.gradio.app/'
|
||||||
PKG_VERSION_URL = "https://api.gradio.app/pkg-version"
|
PKG_VERSION_URL = "https://api.gradio.app/pkg-version"
|
||||||
|
|
||||||
@ -17,15 +20,14 @@ def version_check():
|
|||||||
"is available, please upgrade.".format(
|
"is available, please upgrade.".format(
|
||||||
current_pkg_version, latest_pkg_version))
|
current_pkg_version, latest_pkg_version))
|
||||||
print('--------')
|
print('--------')
|
||||||
|
|
||||||
except pkg_resources.DistributionNotFound:
|
except pkg_resources.DistributionNotFound:
|
||||||
raise RuntimeError("gradio is not setup or installed properly. Unable to get version info.")
|
raise RuntimeError("gradio is not setup or installed properly. Unable to get version info.")
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
raise RuntimeWarning("Unable to parse version details from package URL.")
|
print("Warning: unable to parse version details from package URL.")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise RuntimeWarning("Package URL does not contain version info.")
|
print("Warning: Package URL does not contain version info.")
|
||||||
except ConnectionError:
|
except:
|
||||||
raise RuntimeWarning("Unable to connect with package URL to collect version info.")
|
print("Warning: unable to connect with package URL to collect version info.")
|
||||||
|
|
||||||
|
|
||||||
def error_analytics(type):
|
def error_analytics(type):
|
||||||
|
Loading…
Reference in New Issue
Block a user