summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-06-06 18:17:59 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-06-06 18:17:59 -0700
commit50d7b3df2bb9ef3ce36262cec77595ee7704c301 (patch)
treeecf44cdf303c1efd92c1f9113d81f991622d6b1a /lib
parent8215c85619ccb405d809b0dbc1127685d68210c9 (diff)
parentc43b5d670bf45ed6346db7d498b537ff70c7dbb0 (diff)
downloadspack-50d7b3df2bb9ef3ce36262cec77595ee7704c301.tar.gz
spack-50d7b3df2bb9ef3ce36262cec77595ee7704c301.tar.bz2
spack-50d7b3df2bb9ef3ce36262cec77595ee7704c301.tar.xz
spack-50d7b3df2bb9ef3ce36262cec77595ee7704c301.zip
Merge branch 'psaravan-fastmath' into features/fastmath
Conflicts: var/spack/packages/lapack/package.py
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/filesystem.py12
-rw-r--r--lib/spack/spack/build_environment.py4
-rw-r--r--lib/spack/spack/error.py15
-rw-r--r--lib/spack/spack/package.py11
-rw-r--r--lib/spack/spack/util/executable.py5
5 files changed, 35 insertions, 12 deletions
diff --git a/lib/spack/llnl/util/filesystem.py b/lib/spack/llnl/util/filesystem.py
index 3b34e04740..029a7536df 100644
--- a/lib/spack/llnl/util/filesystem.py
+++ b/lib/spack/llnl/util/filesystem.py
@@ -25,7 +25,7 @@
__all__ = ['set_install_permissions', 'install', 'install_tree', 'traverse_tree',
'expand_user', 'working_dir', 'touch', 'touchp', 'mkdirp',
'force_remove', 'join_path', 'ancestor', 'can_access', 'filter_file',
- 'change_sed_delimiter', 'is_exe', 'force_symlink']
+ 'FileFilter', 'change_sed_delimiter', 'is_exe', 'force_symlink']
import os
import sys
@@ -40,7 +40,6 @@ from tempfile import NamedTemporaryFile
import llnl.util.tty as tty
from spack.util.compression import ALLOWED_ARCHIVE_TYPES
-
def filter_file(regex, repl, *filenames, **kwargs):
"""Like sed, but uses python regular expressions.
@@ -97,6 +96,15 @@ def filter_file(regex, repl, *filenames, **kwargs):
shutil.rmtree(backup, ignore_errors=True)
+class FileFilter(object):
+ """Convenience class for calling filter_file a lot."""
+ def __init__(self, *filenames):
+ self.filenames = filenames
+
+ def filter(self, regex, repl, **kwargs):
+ return filter_file(regex, repl, *self.filenames, **kwargs)
+
+
def change_sed_delimiter(old_delim, new_delim, *filenames):
"""Find all sed search/replace commands and change the delimiter.
e.g., if the file contains seds that look like 's///', you can
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index f9e795ac42..81fbedc689 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -280,6 +280,10 @@ def fork(pkg, function):
# Use os._exit here to avoid raising a SystemExit exception,
# which interferes with unit tests.
os._exit(0)
+
+ except spack.error.SpackError, e:
+ e.die()
+
except:
# Child doesn't raise or return to main spack code.
# Just runs default exception handler and exits.
diff --git a/lib/spack/spack/error.py b/lib/spack/spack/error.py
index e8fa756682..bfa7951a47 100644
--- a/lib/spack/spack/error.py
+++ b/lib/spack/spack/error.py
@@ -22,6 +22,10 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
+import os
+import sys
+import llnl.util.tty as tty
+import spack
class SpackError(Exception):
"""This is the superclass for all Spack errors.
@@ -38,6 +42,17 @@ class SpackError(Exception):
return self._long_message
+ def die(self):
+ if spack.debug:
+ sys.excepthook(*sys.exc_info())
+ os._exit(1)
+ else:
+ tty.error(self.message)
+ if self.long_message:
+ print self.long_message
+ os._exit(1)
+
+
def __str__(self):
msg = self.message
if self.long_message:
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 5dd410d0e4..e3d766f582 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -816,17 +816,8 @@ class Package(object):
except ProcessError, e:
# Annotate with location of build log.
e.build_log = log_path
-
- # One of the processes returned an error code.
- # Suppress detailed stack trace here unless in debug mode
- if spack.debug:
- raise e
- else:
- tty.error(e)
-
- # Still need to clean up b/c there was an error.
cleanup()
- os._exit(1)
+ raise e
except:
# other exceptions just clean up and raise.
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 6eede0f78e..1dcda0d87f 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -124,6 +124,11 @@ class Executable(object):
return "<exe: %s>" % self.exe
+ def __str__(self):
+ return ' '.join(self.exe)
+
+
+
def which(name, **kwargs):
"""Finds an executable in the path like command-line which."""
path = kwargs.get('path', os.environ.get('PATH', '').split(os.pathsep))