|
22 | 22 | import os |
23 | 23 | import re |
24 | 24 | from argparse import ArgumentParser, RawDescriptionHelpFormatter |
| 25 | +from json import loads as json_loads |
25 | 26 | from time import monotonic |
26 | 27 |
|
27 | 28 | import requests |
| 29 | +from requests_futures.sessions import FuturesSession |
28 | 30 |
|
29 | | -# Removing __version__ here will trigger update message for users |
30 | | -# Do not remove until ready to trigger that message |
31 | | -# When removed, also remove all the noqa: E402 comments for linting |
32 | | -__version__ = "0.14.4" |
33 | | -del __version__ |
34 | | - |
35 | | -from sherlock_project.__init__ import ( # noqa: E402 |
| 31 | +from sherlock_project.__init__ import ( |
36 | 32 | __longname__, |
37 | | - __version__ |
| 33 | + __shortname__, |
| 34 | + __version__, |
| 35 | + forge_api_latest_release, |
38 | 36 | ) |
39 | 37 |
|
40 | | -from requests_futures.sessions import FuturesSession # noqa: E402 |
41 | | -from torrequest import TorRequest # noqa: E402 |
42 | | -from sherlock_project.result import QueryStatus # noqa: E402 |
43 | | -from sherlock_project.result import QueryResult # noqa: E402 |
44 | | -from sherlock_project.notify import QueryNotify # noqa: E402 |
45 | | -from sherlock_project.notify import QueryNotifyPrint # noqa: E402 |
46 | | -from sherlock_project.sites import SitesInformation # noqa: E402 |
47 | | -from colorama import init # noqa: E402 |
48 | | -from argparse import ArgumentTypeError # noqa: E402 |
| 38 | +from sherlock_project.result import QueryStatus |
| 39 | +from sherlock_project.result import QueryResult |
| 40 | +from sherlock_project.notify import QueryNotify |
| 41 | +from sherlock_project.notify import QueryNotifyPrint |
| 42 | +from sherlock_project.sites import SitesInformation |
| 43 | +from colorama import init |
| 44 | +from argparse import ArgumentTypeError |
49 | 45 |
|
50 | 46 |
|
51 | 47 | class SherlockFuturesSession(FuturesSession): |
@@ -560,7 +556,7 @@ def main(): |
560 | 556 | parser.add_argument( |
561 | 557 | "--version", |
562 | 558 | action="version", |
563 | | - version=f"Sherlock v{__version__}", |
| 559 | + version=f"{__shortname__} v{__version__}", |
564 | 560 | help="Display version information and dependencies.", |
565 | 561 | ) |
566 | 562 | parser.add_argument( |
@@ -715,17 +711,14 @@ def main(): |
715 | 711 |
|
716 | 712 | # Check for newer version of Sherlock. If it exists, let the user know about it |
717 | 713 | try: |
718 | | - r = requests.get( |
719 | | - "https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/__init__.py" |
720 | | - ) |
721 | | - |
722 | | - remote_version = str(re.findall('__version__ *= *"(.*)"', r.text)[0]) |
723 | | - local_version = __version__ |
| 714 | + latest_release_raw = requests.get(forge_api_latest_release).text |
| 715 | + latest_release_json = json_loads(latest_release_raw) |
| 716 | + latest_remote_tag = latest_release_json["tag_name"] |
724 | 717 |
|
725 | | - if remote_version != local_version: |
| 718 | + if latest_remote_tag[1:] != __version__: |
726 | 719 | print( |
727 | | - "Update Available!\n" |
728 | | - + f"You are running version {local_version}. Version {remote_version} is available at https://github.com/sherlock-project/sherlock" |
| 720 | + f"Update available! {__version__} --> {latest_remote_tag[1:]}" |
| 721 | + f"\n{latest_release_json['html_url']}" |
729 | 722 | ) |
730 | 723 |
|
731 | 724 | except Exception as error: |
|
0 commit comments