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)