summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-10-23 16:51:11 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2017-10-24 10:05:36 +0200
commit5449884b2ecd84f61287923aaffa867d07cbf026 (patch)
tree290048d0cfaaa8347c2329e168e8f47875f651cd /lib
parentb98fc48273b4e2a6f0ae776a5956a7593db65cc5 (diff)
downloadspack-5449884b2ecd84f61287923aaffa867d07cbf026.tar.gz
spack-5449884b2ecd84f61287923aaffa867d07cbf026.tar.bz2
spack-5449884b2ecd84f61287923aaffa867d07cbf026.tar.xz
spack-5449884b2ecd84f61287923aaffa867d07cbf026.zip
Fix bare 'except:' to placate errors in new flake8 version.
- fixes E722 errors from latest version of flake8 - requires us to not use 'bare except:' and catch BaseException instead
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/filesystem.py2
-rw-r--r--lib/spack/llnl/util/tty/__init__.py4
-rw-r--r--lib/spack/llnl/util/tty/colify.py2
-rw-r--r--lib/spack/llnl/util/tty/log.py6
-rw-r--r--lib/spack/spack/build_environment.py2
-rw-r--r--lib/spack/spack/cmd/create.py6
-rw-r--r--lib/spack/spack/cmd/install.py2
-rw-r--r--lib/spack/spack/database.py4
-rw-r--r--lib/spack/spack/fetch_strategy.py2
-rw-r--r--lib/spack/spack/main.py4
-rw-r--r--lib/spack/spack/test/llnl/util/lock.py4
-rw-r--r--lib/spack/spack/util/module_cmd.py4
12 files changed, 21 insertions, 21 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 5ed4d9249a..56b96b3a32 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -130,7 +130,7 @@ def filter_file(regex, repl, *filenames, **kwargs):
try:
for line in fileinput.input(filename, inplace=True):
print(re.sub(regex, repl, line.rstrip('\n')))
- except:
+ except BaseException:
# clean up the original file on failure.
shutil.move(backup_filename, filename)
raise
diff --git a/lib/spack/llnl/util/tty/__init__.py b/lib/spack/llnl/util/tty/__init__.py
index ac51d201aa..5668f73388 100644
--- a/lib/spack/llnl/util/tty/__init__.py
+++ b/lib/spack/llnl/util/tty/__init__.py
@@ -250,7 +250,7 @@ def terminal_size():
try:
rc = struct.unpack('hh', fcntl.ioctl(
fd, termios.TIOCGWINSZ, '1234'))
- except:
+ except BaseException:
return
return rc
rc = ioctl_GWINSZ(0) or ioctl_GWINSZ(1) or ioctl_GWINSZ(2)
@@ -259,7 +259,7 @@ def terminal_size():
fd = os.open(os.ctermid(), os.O_RDONLY)
rc = ioctl_GWINSZ(fd)
os.close(fd)
- except:
+ except BaseException:
pass
if not rc:
rc = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
diff --git a/lib/spack/llnl/util/tty/colify.py b/lib/spack/llnl/util/tty/colify.py
index b04775b4f1..c70d796955 100644
--- a/lib/spack/llnl/util/tty/colify.py
+++ b/lib/spack/llnl/util/tty/colify.py
@@ -167,7 +167,7 @@ def colify(elts, **options):
r, c = env_size.split('x')
console_rows, console_cols = int(r), int(c)
tty = True
- except:
+ except BaseException:
pass
# Use only one column if not a tty.
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index 02084cc382..e8f3ce4d57 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -166,7 +166,7 @@ def _file_descriptors_work(*streams):
for stream in streams:
stream.fileno()
return True
- except:
+ except BaseException:
return False
@@ -310,7 +310,7 @@ class log_output(object):
# need to pass this b/c multiprocessing closes stdin in child.
try:
input_stream = os.fdopen(os.dup(sys.stdin.fileno()))
- except:
+ except BaseException:
input_stream = None # just don't forward input if this fails
self.process = multiprocessing.Process(
@@ -483,7 +483,7 @@ class log_output(object):
force_echo = True
if xoff in controls:
force_echo = False
- except:
+ except BaseException:
tty.error("Exception occurred in writer daemon!")
traceback.print_exc()
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index cc03374769..aac1d38f5a 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -567,7 +567,7 @@ def fork(pkg, function, dirty, fake):
tty.msg(e.message)
child_pipe.send(None)
- except:
+ except BaseException:
# catch ANYTHING that goes wrong in the child process
exc_type, exc, tb = sys.exc_info()
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index d38f11f63b..d0c6c37e29 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -34,7 +34,7 @@ import spack.util.web
from llnl.util.filesystem import mkdirp
from spack.repository import Repo
from spack.spec import Spec
-from spack.util.executable import which
+from spack.util.executable import which, ProcessError
from spack.util.naming import mod_to_class
from spack.util.naming import simplify_name, valid_fully_qualified_module_name
from spack.url import UndetectableNameError, UndetectableVersionError
@@ -471,14 +471,14 @@ class BuildSystemGuesser:
try:
unzip = which('unzip')
output = unzip('-lq', stage.archive_file, output=str)
- except:
+ except ProcessError:
output = ''
else:
try:
tar = which('tar')
output = tar('--exclude=*/*/*', '-tf',
stage.archive_file, output=str)
- except:
+ except ProcessError:
output = ''
lines = output.split('\n')
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index d4a59c9e8f..7c014e0a92 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -286,7 +286,7 @@ def junit_output(spec, test_suite):
message='Unexpected exception thrown during install',
text=text
)
- except:
+ except BaseException:
# Anything else is also an error
duration = time.time() - start_time
test_case.set_duration(duration)
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index 46e8a5ae2e..91142579d5 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -491,7 +491,7 @@ class Database(object):
self._check_ref_counts()
- except:
+ except BaseException:
# If anything explodes, restore old data, skip write.
self._data = old_data
raise
@@ -544,7 +544,7 @@ class Database(object):
with open(temp_file, 'w') as f:
self._write_to_file(f)
os.rename(temp_file, self._index_path)
- except:
+ except BaseException:
# Clean up temp file if something goes wrong.
if os.path.exists(temp_file):
os.remove(temp_file)
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 4ab76c8d2a..9aa6b9afd1 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -970,7 +970,7 @@ def from_list_url(pkg):
except KeyError:
tty.msg("Can not find version %s in url_list" %
pkg.version)
- except:
+ except BaseException:
tty.msg("Could not determine url from list_url.")
diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py
index 775873df23..646969859a 100644
--- a/lib/spack/spack/main.py
+++ b/lib/spack/spack/main.py
@@ -410,8 +410,8 @@ class SpackCommand(object):
except SystemExit as e:
self.returncode = e.code
- except:
- self.error = sys.exc_info()[1]
+ except BaseException as e:
+ self.error = e
if fail_on_error:
raise
diff --git a/lib/spack/spack/test/llnl/util/lock.py b/lib/spack/spack/test/llnl/util/lock.py
index 4466d5999b..4d74d68d73 100644
--- a/lib/spack/spack/test/llnl/util/lock.py
+++ b/lib/spack/spack/test/llnl/util/lock.py
@@ -98,7 +98,7 @@ try:
comm = MPI.COMM_WORLD
if comm.size > 1:
mpi = True
-except:
+except ImportError:
pass
@@ -234,7 +234,7 @@ def mpi_multiproc_test(*functions):
if include:
try:
functions[subcomm.rank](subcomm_barrier())
- except:
+ except BaseException:
# aborting is the best we can do for MPI tests without
# hanging, since we're using MPI barriers. This will fail
# early and it loses the nice pytest output, but at least it
diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py
index a726023d95..6a1db6d221 100644
--- a/lib/spack/spack/util/module_cmd.py
+++ b/lib/spack/spack/util/module_cmd.py
@@ -82,13 +82,13 @@ def get_module_cmd_from_bash(bashopts=''):
try:
find_exec = re.search(r'.*`(.*(:? bash | sh ).*)`.*', module_func)
exec_line = find_exec.group(1)
- except:
+ except BaseException:
try:
# This will fail with nested parentheses. TODO: expand regex.
find_exec = re.search(r'.*\(([^()]*(:? bash | sh )[^()]*)\).*',
module_func)
exec_line = find_exec.group(1)
- except:
+ except BaseException:
raise ModuleError('get_module_cmd cannot '
'determine the module command from bash')