Hello,
In my case I used modules from python with the following logic:
import os
exec(open(/home/jrp/modules/init/python.py')).read())
module('avail')
module('load', 'gcc/7')
module('list')
From the above example,
* exec call will allow me to use modules from python itself and define
module function
* Each module function invocation will be redirected to module to
perform required action
As reminder, the content of stdout is used by modules to setup all
required environment functions, functions/alias (if supported by current
shell), ...
I hope it will help you.
Jacques
Le 21/03/2022 à 20:09, Jonathan Buck a écrit :
> Hi,
>
> I'm attempting to capture and act on the stdout and stderr of the
> module command. The python implementation appears to be a subprocess
> for which I wasn't able to redirect with io.StringIO() as I have with
> other output capture.
>
> I attempted to look through the code, which I admit I don't fully
> understand and appears to have a one-liner style of executing the
> subprocess. I'm writing code that integrates with a production
> system, so I'm not able to modify the python.py code.
>
> Does anyone know how else this might be accomplished? Or should I
> make this a feature request?
>
> Thanks for your help,
> Jonathan
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest |