From 246fd5d620fd56f718bd8ef60a861250b2215370 Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Tue, 21 Nov 2023 07:23:06 +0100 Subject: [PATCH 1/2] Change order of CLI opts and extend parser for ModulesInfo. Fixes #26 --- machinestate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/machinestate.py b/machinestate.py index 848d48e..c0d298b 100755 --- a/machinestate.py +++ b/machinestate.py @@ -2983,7 +2983,7 @@ def __init__(self, extended=False, anonymous=False, modulecmd="modulecmd"): anonymous=anonymous) self.modulecmd = modulecmd parse = ModulesInfo.parsemodules - cmd_opts = "sh list -t 2>&1" + cmd_opts = "sh -t list 2>&1" cmd = modulecmd abspath = which(cmd) if modulecmd is not None and len(modulecmd) > 0: @@ -3001,8 +3001,10 @@ def __init__(self, extended=False, anonymous=False, modulecmd="modulecmd"): self.addc("Loaded", abscmd, cmd_opts, None, parse) @staticmethod def parsemodules(value): - slist = re.split("\n", value) - return slist[1:] + slist = [ x for x in re.split("\n", value) if ";" not in x ] + if re.match("^Currently Loaded.+$", slist[0]): + slist = slist[1:] + return slist ################################################################################ # Infos about interrupt handling From 0d72fb9ed24ef5dbb1a6403b352e5ccda9b9434e Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Tue, 21 Nov 2023 07:24:16 +0100 Subject: [PATCH 2/2] Check for Lmod command in LMOD_CMD env variable --- machinestate.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/machinestate.py b/machinestate.py index c0d298b..00512b3 100755 --- a/machinestate.py +++ b/machinestate.py @@ -2981,6 +2981,8 @@ def __init__(self, extended=False, anonymous=False, modulecmd="modulecmd"): super(ModulesInfo, self).__init__(name="ModulesInfo", extended=extended, anonymous=anonymous) + if os.getenv("LMOD_CMD"): + modulecmd = os.getenv("LMOD_CMD") self.modulecmd = modulecmd parse = ModulesInfo.parsemodules cmd_opts = "sh -t list 2>&1"