package: support verbosity when activating

This commit is contained in:
Oliver Breitwieser 2017-09-14 14:28:11 -04:00 committed by scheibelp
parent af0cf2d3c6
commit 70d3558596

View file

@ -1773,7 +1773,7 @@ def _sanity_check_extension(self):
raise ActivationError("%s does not extend %s!" % raise ActivationError("%s does not extend %s!" %
(self.name, self.extendee.name)) (self.name, self.extendee.name))
def do_activate(self, force=False): def do_activate(self, force=False, verbose=True):
"""Called on an extension to invoke the extendee's activate method. """Called on an extension to invoke the extendee's activate method.
Commands should call this routine, and should not call Commands should call this routine, and should not call
@ -1788,14 +1788,17 @@ def do_activate(self, force=False):
if not force: if not force:
for spec in self.dependency_activations(): for spec in self.dependency_activations():
if not spec.package.is_activated(): if not spec.package.is_activated():
spec.package.do_activate(force=force) spec.package.do_activate(force=force, verbose=verbose)
self.extendee_spec.package.activate(self, **self.extendee_args) self.extendee_spec.package.activate(self, **self.extendee_args)
spack.store.layout.add_extension(self.extendee_spec, self.spec) spack.store.layout.add_extension(self.extendee_spec, self.spec)
tty.msg(
"Activated extension %s for %s" % if verbose:
(self.spec.short_spec, self.extendee_spec.cformat("$_$@$+$%@"))) tty.msg(
"Activated extension %s for %s" %
(self.spec.short_spec,
self.extendee_spec.cformat("$_$@$+$%@")))
def dependency_activations(self): def dependency_activations(self):
return (spec for spec in self.spec.traverse(root=False, deptype='run') return (spec for spec in self.spec.traverse(root=False, deptype='run')
@ -1826,6 +1829,7 @@ def do_deactivate(self, **kwargs):
"""Called on the extension to invoke extendee's deactivate() method.""" """Called on the extension to invoke extendee's deactivate() method."""
self._sanity_check_extension() self._sanity_check_extension()
force = kwargs.get('force', False) force = kwargs.get('force', False)
verbose = kwargs.get("verbose", True)
# Allow a force deactivate to happen. This can unlink # Allow a force deactivate to happen. This can unlink
# spurious files if something was corrupted. # spurious files if something was corrupted.
@ -1853,9 +1857,11 @@ def do_deactivate(self, **kwargs):
spack.store.layout.remove_extension( spack.store.layout.remove_extension(
self.extendee_spec, self.spec) self.extendee_spec, self.spec)
tty.msg( if verbose:
"Deactivated extension %s for %s" % tty.msg(
(self.spec.short_spec, self.extendee_spec.cformat("$_$@$+$%@"))) "Deactivated extension %s for %s" %
(self.spec.short_spec,
self.extendee_spec.cformat("$_$@$+$%@")))
def deactivate(self, extension, **kwargs): def deactivate(self, extension, **kwargs):
"""Unlinks all files from extension out of this package's install dir. """Unlinks all files from extension out of this package's install dir.