Files
modules/init/python.in
Xavier Delaruelle fce5ac6733 init: normalize use and replacement of MODULESHOME
Simplify guess of MODULESHOME location by more relying on 'make'
capabilities than 'perl'.

Adapt init scripts for the different shells to use the MODULESHOME
variable that is replaced during the 'make' process rather than
${MODULESHOME}, $env(MODULESHOME), etc.

By the way, use a replacement pattern closer to what 'configure' is using
with '@MODULESHOME@' rather than '$MODULESHOME' which was confusing in
shell scripts.
2017-03-05 09:21:59 +01:00

24 lines
671 B
Plaintext

import os, subprocess
if 'TCLSH' in os.environ:
TCLSH=os.environ['TCLSH']
else:
if os.path.exists('/usr/bin/tclsh'):
TCLSH="/usr/bin/tclsh"
else:
if os.path.exists('/bin/tclsh') :
TCLSH="/bin/tclsh"
else:
TCLSH=""
if not 'MODULEPATH' in os.environ:
os.environ['MODULEPATH'] = '/mips/tools/freeware/modulefiles'
if not 'LOADEDMODULES' in os.environ:
os.environ['LOADEDMODULES'] = '';
def module(command, *arguments):
exec(subprocess.Popen([TCLSH, '@MODULESHOME@/modulecmd.tcl', 'python', command] + list(arguments), stdout=subprocess.PIPE).communicate()[0])
os.environ['MODULESHOME'] = '@MODULESHOME@'