Skip to content
Snippets Groups Projects
Commit c24f9772 authored by Alan De Smet's avatar Alan De Smet
Browse files

Never catch all exceptions

It was eaching KeyboardInterrupt and causing me grief.
(A small exception is granted for a case that does cleanup and re-raises
te exception.)
parent 49657ebe
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ def logprogress(msg): ...@@ -42,7 +42,7 @@ def logprogress(msg):
try: try:
logging.progress(msg) logging.progress(msg)
return return
except: except Exception:
pass pass
logging.info(msg) logging.info(msg)
...@@ -367,7 +367,7 @@ def download_all(url_to_dst, download_stats, do_download, timeout): ...@@ -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_to_file_no_lock(url, path, file, timeout)
download_successful("download_all success", path, atomic.final_size(), download_stats) 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 # 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 # stuff we might have downloaded. Wipe it out, as it's all or
# nothing # nothing
...@@ -838,7 +838,7 @@ class Downloader: ...@@ -838,7 +838,7 @@ class Downloader:
try: try:
logging.debug("Data set successfully acquired. Problems encountered and resolved:") logging.debug("Data set successfully acquired. Problems encountered and resolved:")
dump_problems(logging.debug, problems) dump_problems(logging.debug, problems)
except: except Exception:
# Don't cause grief over logging problems here # Don't cause grief over logging problems here
# since any exceptions will retry downloads # since any exceptions will retry downloads
# when we already have the files! # when we already have the files!
...@@ -859,7 +859,7 @@ class Downloader: ...@@ -859,7 +859,7 @@ class Downloader:
try: try:
first = problems[0][0] first = problems[0][0]
except: except IndexError:
first = "" first = ""
raise DownloadsFailedException("Errors occurred during download, including "+first) raise DownloadsFailedException("Errors occurred during download, including "+first)
...@@ -940,7 +940,7 @@ class Downloader: ...@@ -940,7 +940,7 @@ class Downloader:
try: try:
self.download_first_available(filesets, dst, timeout=timeout, retries=1, retry_wait=1, download_stats = download_stats) 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, # We just keep trucking on; missed files are unfortunate,
# but not much we can do. # but not much we can do.
pass pass
... ...
......
...@@ -74,7 +74,7 @@ class ExclusiveLockFile: ...@@ -74,7 +74,7 @@ class ExclusiveLockFile:
self.file = None self.file = None
self.filename = filename_or_file self.filename = filename_or_file
logger.debug(f"ExclusiveLockFile({filename_or_file}) is path-like") logger.debug(f"ExclusiveLockFile({filename_or_file}) is path-like")
except: except Exception:
# Not Path-like? I hope it's file-like # Not Path-like? I hope it's file-like
self.file = filename_or_file self.file = filename_or_file
self.filename = None self.filename = None
...@@ -233,7 +233,7 @@ def unlink_if_possible(filename): ...@@ -233,7 +233,7 @@ def unlink_if_possible(filename):
try: try:
os.unlink(filename) os.unlink(filename)
return True return True
except: except OSError:
return False return False
class AtomicCreateIfMissing: class AtomicCreateIfMissing:
... ...
......
...@@ -42,11 +42,11 @@ def roundtozero(value, step = None, offset = None): ...@@ -42,11 +42,11 @@ def roundtozero(value, step = None, offset = None):
""" """
try: try:
if step is None: step = type(value)(1) 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.") raise ValueError("roundtozero: Unable to construct a default step using type(value)(1); you'll need to pass step is explicitly.")
try: try:
if offset is None: offset = type(value)() 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.") raise ValueError("roundtozero: Unable to construct a default step using type(value)(); you'll need to pass step is explicitly.")
offset_value = value - offset offset_value = value - offset
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment