Skip to content

Commit

Permalink
Ensure module setup is sourced before list
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfouca committed Aug 10, 2016
1 parent 77871de commit 4dd30c6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions utils/python/CIME/XML/env_mach_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ def load_modules(self, modules_to_load):
expect(False, "Unhandled module system '%s'" % module_system)

def list_modules(self):
import subprocess
module_system = self.get_module_system_type()

# If the user's login shell is not sh, it's possible that modules
# won't be configured so we need to be sure to source the module
# setup script if it exists.
init_path = self.get_module_system_init_path("sh")
if init_path:
source_cmd = "source %s && " % init_path
else:
source_cmd = ""

if (module_system == "module"):
return run_cmd_no_fail("module list", arg_stderr=subprocess.STDOUT)
return run_cmd_no_fail("%smodule list 2>&1" % source_cmd)
elif (module_system == "soft"):
return run_cmd_no_fail("softenv")
return run_cmd_no_fail("%ssoftenv" % source_cmd)
elif (module_system == "dotkit"):
return run_cmd_no_fail("use -lv")
return run_cmd_no_fail("%suse -lv" % source_cmd)
elif (module_system == "none"):
return ""
else:
Expand Down

0 comments on commit 4dd30c6

Please sign in to comment.