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.
This commit is contained in:
parent
b7c31cb561
commit
b2c2cbadcd
@ -99,9 +99,17 @@ def get_module_cmd_from_bash(bashopts=''):
|
|||||||
def unload_module(mod):
|
def unload_module(mod):
|
||||||
"""Takes a module name and unloads the module from the environment. It does
|
"""Takes a module name and unloads the module from the environment. It does
|
||||||
not check whether conflicts arise from the unloaded module"""
|
not check whether conflicts arise from the unloaded module"""
|
||||||
|
tty.debug("Unloading module: {0}".format(mod))
|
||||||
|
|
||||||
modulecmd = get_module_cmd()
|
modulecmd = get_module_cmd()
|
||||||
exec(compile(modulecmd('unload', mod, output=str, error=str), '<string>',
|
unload_output = modulecmd('unload', mod, output=str, error=str)
|
||||||
'exec'))
|
|
||||||
|
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):
|
def load_module(mod):
|
||||||
@ -109,6 +117,8 @@ def load_module(mod):
|
|||||||
load that module. It then loads the provided module. Depends on the
|
load that module. It then loads the provided module. Depends on the
|
||||||
modulecmd implementation of modules used in cray and lmod.
|
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
|
# Create an executable of the module command that will output python code
|
||||||
modulecmd = get_module_cmd()
|
modulecmd = get_module_cmd()
|
||||||
|
|
||||||
@ -116,17 +126,28 @@ def load_module(mod):
|
|||||||
# We do this without checking that they are already installed
|
# We do this without checking that they are already installed
|
||||||
# for ease of programming because unloading a module that is not
|
# for ease of programming because unloading a module that is not
|
||||||
# loaded does nothing.
|
# loaded does nothing.
|
||||||
text = modulecmd('show', mod, output=str, error=str).split()
|
module_content = modulecmd('show', mod, output=str, error=str)
|
||||||
for i, word in enumerate(text):
|
text = module_content.split()
|
||||||
if word == 'conflict':
|
try:
|
||||||
unload_module(text[i + 1])
|
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
|
# Load the module now that there are no conflicts
|
||||||
# Some module systems use stdout and some use stderr
|
# Some module systems use stdout and some use stderr
|
||||||
load = modulecmd('load', mod, output=str, error='/dev/null')
|
load = modulecmd('load', mod, output=str, error='/dev/null')
|
||||||
if not load:
|
if not load:
|
||||||
load = modulecmd('load', mod, error=str)
|
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):
|
def get_path_arg_from_module_line(line):
|
||||||
|
Loading…
Reference in New Issue
Block a user