From 15012f0e916e4b45161ba0dfe551eb8e2a69367a Mon Sep 17 00:00:00 2001 From: Siddharth Dushantha Date: Sun, 9 Aug 2020 07:44:44 +0200 Subject: [PATCH] added error checking while checking for updates --- sherlock/sherlock.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index 6ac01fdc..015a411e 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -494,13 +494,19 @@ def main(): args = parser.parse_args() # Check for newer version of Sherlock. If it exists, let the user know about it - r = requests.get("https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/sherlock.py") - remote_version = str(re.findall('__version__ = "(.*)"', r.text)[0]) - local_version = __version__ - if remote_version != local_version: - print("Update Available!\n" + - f"You are running version {local_version}. Version {remote_version} is available at https://git.io/sherlock") + try: + r = requests.get("https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/sherlock.py") + + remote_version = str(re.findall('__version__ = "(.*)"', r.text)[0]) + local_version = __version__ + + if remote_version != local_version: + print("Update Available!\n" + + f"You are running version {local_version}. Version {remote_version} is available at https://git.io/sherlock") + + except Exception as error: + print(f"A problem occured while checking for an update: {error}") # Argument check