diff --git a/sherlock_project/__init__.py b/sherlock_project/__init__.py index 91f8f66e..52307cd7 100644 --- a/sherlock_project/__init__.py +++ b/sherlock_project/__init__.py @@ -10,4 +10,6 @@ import_error_test_var = None __shortname__ = "Sherlock" __longname__ = "Sherlock: Find Usernames Across Social Networks" -__version__ = "0.14.4" +__version__ = "0.15.0" + +forge_api_latest_release = "https://api.github.com/repos/sherlock-project/sherlock/releases/latest" diff --git a/sherlock_project/sherlock.py b/sherlock_project/sherlock.py index f805b0c6..2464e04c 100644 --- a/sherlock_project/sherlock.py +++ b/sherlock_project/sherlock.py @@ -22,30 +22,26 @@ import pandas as pd import os import re from argparse import ArgumentParser, RawDescriptionHelpFormatter +from json import loads as json_loads from time import monotonic import requests +from requests_futures.sessions import FuturesSession -# Removing __version__ here will trigger update message for users -# Do not remove until ready to trigger that message -# When removed, also remove all the noqa: E402 comments for linting -__version__ = "0.14.4" -del __version__ - -from sherlock_project.__init__ import ( # noqa: E402 +from sherlock_project.__init__ import ( __longname__, - __version__ + __shortname__, + __version__, + forge_api_latest_release, ) -from requests_futures.sessions import FuturesSession # noqa: E402 -from torrequest import TorRequest # noqa: E402 -from sherlock_project.result import QueryStatus # noqa: E402 -from sherlock_project.result import QueryResult # noqa: E402 -from sherlock_project.notify import QueryNotify # noqa: E402 -from sherlock_project.notify import QueryNotifyPrint # noqa: E402 -from sherlock_project.sites import SitesInformation # noqa: E402 -from colorama import init # noqa: E402 -from argparse import ArgumentTypeError # noqa: E402 +from sherlock_project.result import QueryStatus +from sherlock_project.result import QueryResult +from sherlock_project.notify import QueryNotify +from sherlock_project.notify import QueryNotifyPrint +from sherlock_project.sites import SitesInformation +from colorama import init +from argparse import ArgumentTypeError class SherlockFuturesSession(FuturesSession): @@ -560,7 +556,7 @@ def main(): parser.add_argument( "--version", action="version", - version=f"Sherlock v{__version__}", + version=f"{__shortname__} v{__version__}", help="Display version information and dependencies.", ) parser.add_argument( @@ -715,17 +711,14 @@ def main(): # Check for newer version of Sherlock. If it exists, let the user know about it try: - r = requests.get( - "https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/__init__.py" - ) - - remote_version = str(re.findall('__version__ *= *"(.*)"', r.text)[0]) - local_version = __version__ + latest_release_raw = requests.get(forge_api_latest_release).text + latest_release_json = json_loads(latest_release_raw) + latest_remote_tag = latest_release_json["tag_name"] - if remote_version != local_version: + if latest_remote_tag[1:] != __version__: print( - "Update Available!\n" - + f"You are running version {local_version}. Version {remote_version} is available at https://github.com/sherlock-project/sherlock" + f"Update available! {__version__} --> {latest_remote_tag[1:]}" + f"\n{latest_release_json['html_url']}" ) except Exception as error: diff --git a/tests/test_version.py b/tests/test_version.py index 91842229..2de64ddd 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -11,7 +11,6 @@ def test_versioning() -> None: expected:list = [ # Normalization is REQUIRED for Windows ( / vs \ ) os.path.normpath("sherlock_project/__init__.py"), - os.path.normpath("sherlock_project/sherlock.py"), ] # Sorting is REQUIRED for Mac assert sorted(found) == sorted(expected)