Skip to content

Commit

Permalink
init: explicitly send err output to sys.stderr in python
Browse files Browse the repository at this point in the history
Update python initialization script to explicitly send error output
to the sys.stderr channel (instead of parent process stderr channel) to
be able to catch this content.
  • Loading branch information
xdelaruelle committed Mar 24, 2022
1 parent 5e5aff6 commit 1e4b272
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions init/python.py.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, re, subprocess
from __future__ import print_function
import os, sys, re, subprocess

# define modules runtime quarantine configuration
@setquarvars@os.environ['MODULES_RUN_QUARANTINE'] = '@RUN_QUARANTINE@'
Expand All @@ -21,7 +22,13 @@ if 'MODULES_RUN_QUARANTINE' in os.environ:

# define module command and surrounding initial environment (default value
# for MODULESHOME, MODULEPATH, LOADEDMODULES and parse of init config files)
exec(subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', 'autoinit'], stdout=subprocess.PIPE, env=_mlre).communicate()[0])
out, err = subprocess.Popen(['@TCLSH@', '@libexecdir@/modulecmd.tcl', 'python', 'autoinit'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=_mlre).communicate()

# clean temp variable used to setup quarantine
exec(out)
if err.decode():
print(err.decode(), end='', file=sys.stderr)

# clean temp variables
del _mlre
del out
del err

0 comments on commit 1e4b272

Please sign in to comment.