From 3fa7f4bed5b163cce9409c18a0601549ed957605 Mon Sep 17 00:00:00 2001 From: Alexandre D'Astous Date: Thu, 28 Apr 2022 17:33:15 -0400 Subject: [PATCH] Add exception names in the except clause --- dcm2bids/version.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dcm2bids/version.py b/dcm2bids/version.py index 8429a0cd..dd7a8448 100644 --- a/dcm2bids/version.py +++ b/dcm2bids/version.py @@ -10,7 +10,7 @@ import shlex import socket from distutils.version import LooseVersion -from subprocess import check_output +from subprocess import check_output, CalledProcessError, TimeoutExpired from shutil import which @@ -41,11 +41,14 @@ def check_github_latest(githubRepo, timeout=3): url = "https://github.com/{}/releases/latest".format(githubRepo) try: output = check_output(shlex.split("curl --silent " + url), timeout=timeout) - except: + except CalledProcessError: logger.info(f"Checking latest version of {githubRepo} was not possible") logger.debug(f"Error while 'curl --silent {url}'", exc_info=True) return - + except TimeoutExpired: + logger.info(f"Checking latest version of {githubRepo} was not possible") + logger.debug(f"Command 'curl --silent {url}' timed out after {timeout}s") + return # The output should have this format # You are being redirected. try: