MCPcopy
hub / github.com/deadc0de6/dotdrop / check_version

Function check_version

dotdrop/utils.py:617–647  ·  view source on GitHub ↗

get dotdrop latest version on github compare with "version" and emit warning in case new version is available

()

Source from the content-addressed store, hash-verified

615
616
617def check_version():
618 """
619 get dotdrop latest version on github
620 compare with "version"
621 and emit warning in case new version is available
622 """
623 url = 'https://api.github.com/repos/deadc0de6/dotdrop/releases/latest'
624 try:
625 req = requests.get(url, timeout=1)
626 except requests.exceptions.RequestException:
627 # request failed
628 return
629 if not req:
630 # request failed
631 return
632 if req.status_code != 200:
633 # request failed
634 return
635 # get json
636 try:
637 latest = req.json()['name']
638 except json.decoder.JSONDecodeError:
639 return
640 except ValueError:
641 return
642 # compare
643 if latest.startswith('v'):
644 latest = latest[1:]
645 if version.parse(VERSION) < version.parse(latest):
646 msg = f'A new version of dotdrop is available ({latest})'
647 LOG.warn(msg)
648
649
650def pivot_path(path, newdir, striphome=False, logger=None):

Callers 1

mainFunction · 0.90

Calls 3

getMethod · 0.80
warnMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected