summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2019-01-29 17:41:15 -0600
committerGitHub <noreply@github.com>2019-01-29 17:41:15 -0600
commitb2c2cbadcda1394025605c317e2eb9c2b5b200ba (patch)
tree6c28828cd185843521bd231523a7d90eae0e42ca /lib
parentb7c31cb5616c5637512d8fb5599393dec374ffb1 (diff)
downloadspack-b2c2cbadcda1394025605c317e2eb9c2b5b200ba.tar.gz
spack-b2c2cbadcda1394025605c317e2eb9c2b5b200ba.tar.bz2
spack-b2c2cbadcda1394025605c317e2eb9c2b5b200ba.tar.xz
spack-b2c2cbadcda1394025605c317e2eb9c2b5b200ba.zip
debug output includes modulecmd output (#9476)
Debug output now includes the output of modulecmd executions. Only output module content when a failure occurs; always report when a module is loaded/unloaded.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/module_cmd.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/lib/spack/spack/util/module_cmd.py b/lib/spack/spack/util/module_cmd.py
index a7ceee6d3d..6a1ca8113d 100644
--- a/lib/spack/spack/util/module_cmd.py
+++ b/lib/spack/spack/util/module_cmd.py
@@ -99,9 +99,17 @@ def get_module_cmd_from_bash(bashopts=''):
def unload_module(mod):
"""Takes a module name and unloads the module from the environment. It does
not check whether conflicts arise from the unloaded module"""
+ tty.debug("Unloading module: {0}".format(mod))
+
modulecmd = get_module_cmd()
- exec(compile(modulecmd('unload', mod, output=str, error=str), '<string>',
- 'exec'))
+ unload_output = modulecmd('unload', mod, output=str, error=str)
+
+ try:
+ exec(compile(unload_output, '<string>', 'exec'))
+ except Exception:
+ tty.debug("Module unload output of {0}:\n{1}\n".format(
+ mod, unload_output))
+ raise
def load_module(mod):
@@ -109,6 +117,8 @@ def load_module(mod):
load that module. It then loads the provided module. Depends on the
modulecmd implementation of modules used in cray and lmod.
"""
+ tty.debug("Loading module: {0}".format(mod))
+
# Create an executable of the module command that will output python code
modulecmd = get_module_cmd()
@@ -116,17 +126,28 @@ def load_module(mod):
# We do this without checking that they are already installed
# for ease of programming because unloading a module that is not
# loaded does nothing.
- text = modulecmd('show', mod, output=str, error=str).split()
- for i, word in enumerate(text):
- if word == 'conflict':
- unload_module(text[i + 1])
+ module_content = modulecmd('show', mod, output=str, error=str)
+ text = module_content.split()
+ try:
+ for i, word in enumerate(text):
+ if word == 'conflict':
+ unload_module(text[i + 1])
+ except Exception:
+ tty.debug("Module show output of {0}:\n{1}\n".format(
+ mod, module_content))
+ raise
# Load the module now that there are no conflicts
# Some module systems use stdout and some use stderr
load = modulecmd('load', mod, output=str, error='/dev/null')
if not load:
load = modulecmd('load', mod, error=str)
- exec(compile(load, '<string>', 'exec'))
+
+ try:
+ exec(compile(load, '<string>', 'exec'))
+ except Exception:
+ tty.debug("Module load output of {0}:\n{1}\n".format(mod, load))
+ raise
def get_path_arg_from_module_line(line):