mirror of
https://github.com/envmodules/modules.git
synced 2026-05-30 00:12:31 +08:00
Rename the environment variables used to indirectly pass to `modulecmd.tcl` the value of variables set in quarantine (variables whose name finishes with `_modquar`). A `__MODULES_QUAR_` prefix is applied to the name of these variables instead of the `_modquar` suffix to indicate they are intended for Modules internal use of only.
28 lines
1.6 KiB
Python
28 lines
1.6 KiB
Python
import os, re, subprocess
|
|
|
|
@quarantinesupport@# define modules runtine quarantine configuration
|
|
@quarantinesupport@@setquarvars@os.environ['MODULES_RUN_QUARANTINE'] = '@RUN_QUARANTINE@'
|
|
@quarantinesupport@@setquarvars@@os.environ['RUNENV_VAR'] = 'RUNENV_VAL'@
|
|
@quarantinesupport@@notsetquarvars@#os.environ['MODULES_RUN_QUARANTINE'] = 'ENVVARNAME'
|
|
@quarantinesupport@@notsetquarvars@
|
|
@quarantinesupport@# setup quarantine if defined
|
|
@quarantinesupport@_mlre = os.environ.copy()
|
|
@quarantinesupport@if 'MODULES_RUN_QUARANTINE' in os.environ:
|
|
@quarantinesupport@ for _mlv in os.environ['MODULES_RUN_QUARANTINE'].split():
|
|
@quarantinesupport@ if re.match('^[A-Za-z_][A-Za-z0-9_]*$', _mlv):
|
|
@quarantinesupport@ if _mlv in os.environ:
|
|
@quarantinesupport@ _mlre['__MODULES_QUAR_' + _mlv] = os.environ[_mlv]
|
|
@quarantinesupport@ _mlrv = 'MODULES_RUNENV_' + _mlv
|
|
@quarantinesupport@ if _mlrv in os.environ:
|
|
@quarantinesupport@ _mlre[_mlv] = os.environ[_mlrv]
|
|
@quarantinesupport@ else:
|
|
@quarantinesupport@ _mlre[_mlv] = ''
|
|
@quarantinesupport@
|
|
# define module command and surrounding initial environment (default value
|
|
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files)
|
|
@quarantinesupport@exec(subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', 'autoinit'], stdout=subprocess.PIPE, env=_mlre).communicate()[0])
|
|
@notquarantinesupport@exec(subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', 'autoinit'], stdout=subprocess.PIPE).communicate()[0])
|
|
@quarantinesupport@
|
|
@quarantinesupport@# clean temp variable used to setup quarantine
|
|
@quarantinesupport@del _mlre
|