1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 14:31:46 +00:00

check version fails nicely

This commit is contained in:
deadc0de6
2023-01-29 21:21:48 +01:00
committed by deadc0de
parent 0773acf2b1
commit 9858454a9c

View File

@@ -495,17 +495,31 @@ def debug_dict(title, elems, debug):
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'
req = requests.get(url, timeout=1)
if not req:
try:
req = requests.get(url, timeout=1)
except requests.exceptions.RequestException:
# request failed
return
if not req:
# request failed
return
if req.status_code != 200:
# request failed
return
# get json
try:
latest = req.json()['name']
except json.decoder.JSONDecodeError:
return
except ValueError:
return
# compare
if latest.startswith('v'):
latest = latest[1:]
if version.parse(VERSION) < version.parse(latest):