mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 07:54:15 +00:00
check version fails nicely
This commit is contained in:
@@ -495,17 +495,31 @@ def debug_dict(title, elems, debug):
|
|||||||
|
|
||||||
|
|
||||||
def check_version():
|
def check_version():
|
||||||
"""check dotdrop version on github and compare with current"""
|
"""
|
||||||
|
get dotdrop latest version on github
|
||||||
|
compare with "version"
|
||||||
|
and emit warning in case new version is available
|
||||||
|
"""
|
||||||
url = 'https://api.github.com/repos/deadc0de6/dotdrop/releases/latest'
|
url = 'https://api.github.com/repos/deadc0de6/dotdrop/releases/latest'
|
||||||
req = requests.get(url, timeout=1)
|
try:
|
||||||
if not req:
|
req = requests.get(url, timeout=1)
|
||||||
|
except requests.exceptions.RequestException:
|
||||||
|
# request failed
|
||||||
return
|
return
|
||||||
|
if not req:
|
||||||
|
# request failed
|
||||||
|
return
|
||||||
|
if req.status_code != 200:
|
||||||
|
# request failed
|
||||||
|
return
|
||||||
|
# get json
|
||||||
try:
|
try:
|
||||||
latest = req.json()['name']
|
latest = req.json()['name']
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
return
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return
|
return
|
||||||
|
# compare
|
||||||
if latest.startswith('v'):
|
if latest.startswith('v'):
|
||||||
latest = latest[1:]
|
latest = latest[1:]
|
||||||
if version.parse(VERSION) < version.parse(latest):
|
if version.parse(VERSION) < version.parse(latest):
|
||||||
|
|||||||
Reference in New Issue
Block a user