summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@googlemail.com>2016-10-27 00:17:20 +0200
committerTodd Gamblin <tgamblin@llnl.gov>2016-10-26 15:17:20 -0700
commit37dc719d1357c09d6ef6a53e2ba22627a145a63f (patch)
treec4444f787fe47e834b4e94cef39883646b66f6c1 /lib
parent0007877944b111bec71509ad6011fef11d9bae9e (diff)
downloadspack-37dc719d1357c09d6ef6a53e2ba22627a145a63f.tar.gz
spack-37dc719d1357c09d6ef6a53e2ba22627a145a63f.tar.bz2
spack-37dc719d1357c09d6ef6a53e2ba22627a145a63f.tar.xz
spack-37dc719d1357c09d6ef6a53e2ba22627a145a63f.zip
ProcessError : now the exception is correctly pickled and passed across processes. (#2143)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/__init__.py5
-rw-r--r--lib/spack/spack/util/executable.py38
2 files changed, 32 insertions, 11 deletions
diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py
index 67c64276ee..cadfa95426 100644
--- a/lib/spack/spack/__init__.py
+++ b/lib/spack/spack/__init__.py
@@ -186,7 +186,8 @@ sys_type = None
# packages should live. This file is overloaded for spack core vs.
# for packages.
#
-__all__ = ['Package',
+__all__ = ['PackageBase',
+ 'Package',
'CMakePackage',
'AutotoolsPackage',
'MakefilePackage',
@@ -195,7 +196,7 @@ __all__ = ['Package',
'ver',
'alldeps',
'nolink']
-from spack.package import Package, ExtensionConflictError
+from spack.package import Package, PackageBase, ExtensionConflictError
from spack.build_systems.makefile import MakefilePackage
from spack.build_systems.autotools import AutotoolsPackage
from spack.build_systems.cmake import CMakePackage
diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py
index 2790508ee8..fbcb172f0c 100644
--- a/lib/spack/spack/util/executable.py
+++ b/lib/spack/spack/util/executable.py
@@ -184,11 +184,11 @@ class Executable(object):
result += err
return result
- except OSError, e:
+ except OSError as e:
raise ProcessError(
"%s: %s" % (self.exe[0], e.strerror), "Command: " + cmd_line)
- except subprocess.CalledProcessError, e:
+ except subprocess.CalledProcessError as e:
if fail_on_error:
raise ProcessError(
str(e), "\nExit status %d when invoking command: %s" %
@@ -249,21 +249,41 @@ class ProcessError(spack.error.SpackError):
@property
def long_message(self):
- msg = self._long_message
- if msg:
- msg += "\n\n"
- if self.build_log:
- msg += "See build log for details:\n"
- msg += " %s" % self.build_log
+ msg = self._long_message if self._long_message else ''
if self.package_context:
if msg:
msg += "\n\n"
msg += '\n'.join(self.package_context)
+ if msg:
+ msg += "\n\n"
+
+ if self.build_log:
+ msg += "See build log for details:\n"
+ msg += " %s" % self.build_log
+
return msg
+ def __reduce__(self):
+ # We need this constructor because we are trying to move a ProcessError
+ # across processes. This means that we have to preserve the original
+ # package context and build log
+ return _make_process_error, (
+ self.message,
+ self._long_message,
+ self.package_context,
+ self.build_log
+ )
+
+
+def _make_process_error(msg, long_message, pkg_context, build_log):
+ a = ProcessError(msg, long_message)
+ a.package_context = pkg_context
+ a.build_log = build_log
+ return a
+
def _get_package_context():
"""Return some context for an error message when the build fails.
@@ -291,7 +311,7 @@ def _get_package_context():
# Look only at a frame in a subclass of spack.Package
obj = frame.f_locals['self']
- if type(obj) != spack.Package and isinstance(obj, spack.Package):
+ if type(obj) != spack.PackageBase and isinstance(obj, spack.PackageBase): # NOQA: ignore=E501
break
else:
# Didn't find anything