mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-07-01 11:49:38 +02:00
modulecmd: derive prefix from directory of init scripts
This commit is contained in:
+10
-7
@@ -1,13 +1,16 @@
|
||||
import os, re, subprocess
|
||||
#
|
||||
# :FIXME:
|
||||
# - add error handling
|
||||
# - needs testing!
|
||||
#
|
||||
import subprocess, pathlib
|
||||
|
||||
def module(*args):
|
||||
os.environ['PMODULES_MODULEFILES_DIR']='modulefiles'
|
||||
pm_home=os.environ['PMODULES_HOME']
|
||||
os.environ['PMODULES_DIR']=pm_home
|
||||
modulecmd=os.path.join(pm_home, 'bin', 'modulecmd')
|
||||
dir=pathlib.Path(__file__).parent
|
||||
modulecmd=pathlib.PurePath.joinpath(dir, '..', 'bin', 'modulecmd').resolve()
|
||||
if type(args[0]) == type([]):
|
||||
args = args[0]
|
||||
cmd = [modulecmd, 'python'] + args[0]
|
||||
else:
|
||||
cmd = [modulecmd, 'python'] + list(args)
|
||||
(output, error) = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
|
||||
(output, error) = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
|
||||
exec(output)
|
||||
|
||||
Reference in New Issue
Block a user