ProcessError : now the exception is correctly pickled and passed across processes. (#2143)
This commit is contained in:
parent
0007877944
commit
37dc719d13
@ -186,7 +186,8 @@
|
|||||||
# packages should live. This file is overloaded for spack core vs.
|
# packages should live. This file is overloaded for spack core vs.
|
||||||
# for packages.
|
# for packages.
|
||||||
#
|
#
|
||||||
__all__ = ['Package',
|
__all__ = ['PackageBase',
|
||||||
|
'Package',
|
||||||
'CMakePackage',
|
'CMakePackage',
|
||||||
'AutotoolsPackage',
|
'AutotoolsPackage',
|
||||||
'MakefilePackage',
|
'MakefilePackage',
|
||||||
@ -195,7 +196,7 @@
|
|||||||
'ver',
|
'ver',
|
||||||
'alldeps',
|
'alldeps',
|
||||||
'nolink']
|
'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.makefile import MakefilePackage
|
||||||
from spack.build_systems.autotools import AutotoolsPackage
|
from spack.build_systems.autotools import AutotoolsPackage
|
||||||
from spack.build_systems.cmake import CMakePackage
|
from spack.build_systems.cmake import CMakePackage
|
||||||
|
@ -184,11 +184,11 @@ def streamify(arg, mode):
|
|||||||
result += err
|
result += err
|
||||||
return result
|
return result
|
||||||
|
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
raise ProcessError(
|
raise ProcessError(
|
||||||
"%s: %s" % (self.exe[0], e.strerror), "Command: " + cmd_line)
|
"%s: %s" % (self.exe[0], e.strerror), "Command: " + cmd_line)
|
||||||
|
|
||||||
except subprocess.CalledProcessError, e:
|
except subprocess.CalledProcessError as e:
|
||||||
if fail_on_error:
|
if fail_on_error:
|
||||||
raise ProcessError(
|
raise ProcessError(
|
||||||
str(e), "\nExit status %d when invoking command: %s" %
|
str(e), "\nExit status %d when invoking command: %s" %
|
||||||
@ -249,7 +249,14 @@ def __init__(self, msg, long_message=None):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def long_message(self):
|
def long_message(self):
|
||||||
msg = self._long_message
|
|
||||||
|
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:
|
if msg:
|
||||||
msg += "\n\n"
|
msg += "\n\n"
|
||||||
|
|
||||||
@ -257,13 +264,26 @@ def long_message(self):
|
|||||||
msg += "See build log for details:\n"
|
msg += "See build log for details:\n"
|
||||||
msg += " %s" % self.build_log
|
msg += " %s" % self.build_log
|
||||||
|
|
||||||
if self.package_context:
|
|
||||||
if msg:
|
|
||||||
msg += "\n\n"
|
|
||||||
msg += '\n'.join(self.package_context)
|
|
||||||
|
|
||||||
return msg
|
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():
|
def _get_package_context():
|
||||||
"""Return some context for an error message when the build fails.
|
"""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
|
# Look only at a frame in a subclass of spack.Package
|
||||||
obj = frame.f_locals['self']
|
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
|
break
|
||||||
else:
|
else:
|
||||||
# Didn't find anything
|
# Didn't find anything
|
||||||
|
Loading…
Reference in New Issue
Block a user