mirror of
https://github.com/envmodules/modules.git
synced 2026-06-10 00:56:30 +08:00
Python code used to define the module command (autoinit action) was broken (syntax errors) and not Python3-compatible. Error rendering is also fixed here for Python3 compliance. Code used to process x-resource is adapted to comply with Python recommendation [1] (subprocess.Popen should be used instead of os.popen). Python init script is also modified by this commit to use same code as the one generated by autoinit action with call to subprocess.Popen rather than os.popen. [1] https://docs.python.org/2/library/os.html#os.popen
24 lines
677 B
Plaintext
24 lines
677 B
Plaintext
import os, subprocess
|
|
|
|
os.environ['MODULESHOME'] = '$MODULESHOME'
|
|
|
|
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])
|