From 263ac47838c971e341d46c5cda79752e532a2e32 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Wed, 5 Apr 2023 16:57:55 +0200 Subject: [PATCH] Python init file added --- Pmodules/Pmodules.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Pmodules/Pmodules.py diff --git a/Pmodules/Pmodules.py b/Pmodules/Pmodules.py new file mode 100644 index 0000000..68993e5 --- /dev/null +++ b/Pmodules/Pmodules.py @@ -0,0 +1,14 @@ +import os, re, subprocess + +def module(*args): + os.environ['PMODULES_MODULEFILES_DIR']='modulefiles' + os.environ['PMODULES_CONFIG_DIR']='config' + pm_home=os.environ['PMODULES_HOME'] + os.environ['PMODULES_DIR']=pm_home + modulecmd=os.path.join(pm_home, 'bin', 'modulecmd') + if type(args[0]) == type([]): + args = args[0] + else: + cmd = [modulecmd, 'python'] + list(args) + (output, error) = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate() + exec(output)