diff --git a/csppfetch/__init__.py b/csppfetch/__init__.py index 8f5c468fbb03840d38408b566daa3332a2909b4d..610679053b185026738bcb480d2e7805c6a64862 100644 --- a/csppfetch/__init__.py +++ b/csppfetch/__init__.py @@ -42,7 +42,7 @@ def logprogress(msg): try: logging.progress(msg) return - except: + except Exception: pass logging.info(msg) @@ -367,7 +367,7 @@ def download_all(url_to_dst, download_stats, do_download, timeout): download_to_file_no_lock(url, path, file, timeout) download_successful("download_all success", path, atomic.final_size(), download_stats) - except: + except: # We're going to re-raise the exception. # Files present at start should not be in todo, so this is just # stuff we might have downloaded. Wipe it out, as it's all or # nothing @@ -838,7 +838,7 @@ class Downloader: try: logging.debug("Data set successfully acquired. Problems encountered and resolved:") dump_problems(logging.debug, problems) - except: + except Exception: # Don't cause grief over logging problems here # since any exceptions will retry downloads # when we already have the files! @@ -859,7 +859,7 @@ class Downloader: try: first = problems[0][0] - except: + except IndexError: first = "" raise DownloadsFailedException("Errors occurred during download, including "+first) @@ -940,7 +940,7 @@ class Downloader: try: self.download_first_available(filesets, dst, timeout=timeout, retries=1, retry_wait=1, download_stats = download_stats) - except: + except Exception: # We just keep trucking on; missed files are unfortunate, # but not much we can do. pass diff --git a/csppfetch/exclusivelockfile.py b/csppfetch/exclusivelockfile.py index a900694ab92cc0f5d1493ed9ea43ebe641dc5d54..1c375077b9c7992b10ac2e838cfe4a519887d37c 100644 --- a/csppfetch/exclusivelockfile.py +++ b/csppfetch/exclusivelockfile.py @@ -74,7 +74,7 @@ class ExclusiveLockFile: self.file = None self.filename = filename_or_file logger.debug(f"ExclusiveLockFile({filename_or_file}) is path-like") - except: + except Exception: # Not Path-like? I hope it's file-like self.file = filename_or_file self.filename = None @@ -233,7 +233,7 @@ def unlink_if_possible(filename): try: os.unlink(filename) return True - except: + except OSError: return False class AtomicCreateIfMissing: diff --git a/csppfetch/roundtozero.py b/csppfetch/roundtozero.py index 945ce1a8f3ac6fbb6ffbd8853f43f4f0770dd62c..67bd349ee6d2dfe3897b64afe424dca095910309 100644 --- a/csppfetch/roundtozero.py +++ b/csppfetch/roundtozero.py @@ -42,11 +42,11 @@ def roundtozero(value, step = None, offset = None): """ try: if step is None: step = type(value)(1) - except: + except Exception: raise ValueError("roundtozero: Unable to construct a default step using type(value)(1); you'll need to pass step is explicitly.") try: if offset is None: offset = type(value)() - except: + except Exception: raise ValueError("roundtozero: Unable to construct a default step using type(value)(); you'll need to pass step is explicitly.") offset_value = value - offset