diff --git a/sherlock/__init__.py b/sherlock/__init__.py index 5bf79e243..81e04b6a6 100644 --- a/sherlock/__init__.py +++ b/sherlock/__init__.py @@ -7,4 +7,6 @@ __shortname__ = "Sherlock" __longname__ = "Sherlock: Find Usernames Across Social Networks" -__version__ = "0.14.4" +__version__ = "0.15.0" + +forgeApiLatestReleaseUrl = "https://api.github.com/repos/sherlock-project/sherlock/releases/latest" diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index db8e9c2cb..23c9a4d07 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -14,30 +14,27 @@ import re import sys from argparse import ArgumentParser, RawDescriptionHelpFormatter +from json import loads as json_loads from time import monotonic import requests +from requests_futures.sessions import FuturesSession +from torrequest import TorRequest -# 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 .__init__ import ( # noqa: E402 +from sherlock.__init__ import ( __longname__, - __version__ + __shortname__, + __version__, + forgeApiLatestReleaseUrl, ) -from requests_futures.sessions import FuturesSession # noqa: E402 -from torrequest import TorRequest # noqa: E402 -from sherlock.result import QueryStatus # noqa: E402 -from sherlock.result import QueryResult # noqa: E402 -from sherlock.notify import QueryNotify # noqa: E402 -from sherlock.notify import QueryNotifyPrint # noqa: E402 -from sherlock.sites import SitesInformation # noqa: E402 -from colorama import init # noqa: E402 -from argparse import ArgumentTypeError # noqa: E402 +from sherlock.result import QueryStatus +from sherlock.result import QueryResult +from sherlock.notify import QueryNotify +from sherlock.notify import QueryNotifyPrint +from sherlock.sites import SitesInformation +from colorama import init +from argparse import ArgumentTypeError class SherlockFuturesSession(FuturesSession): @@ -523,7 +520,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( @@ -671,17 +668,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__ + latestReleaseJsonRaw = requests.get(forgeApiLatestReleaseUrl).text + latestReleaseJsonData = json_loads(latestReleaseJsonRaw) + latestRemoteTag = latestReleaseJsonData["tag_name"] - if remote_version != local_version: + if latestRemoteTag[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__} --> {latestRemoteTag[1:]}" + f"\n{latestReleaseJsonData['html_url']}" ) except Exception as error: diff --git a/tests/test_version.py b/tests/test_version.py index 68119c9ed..31578463f 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/__init__.py"), - os.path.normpath("sherlock/sherlock.py"), ] # Sorting is REQUIRED for Mac assert sorted(found) == sorted(expected)