get dotdrop latest version on github compare with "version" and emit warning in case new version is available
()
| 615 | |
| 616 | |
| 617 | def 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 | |
| 650 | def pivot_path(path, newdir, striphome=False, logger=None): |