I would like to start an external application from within a Python subprocess like this:
import subprocess
...
process = subprocess.POpen (shlex.split ("make test-scripts"),
env=my_environment,
stdout=my_logfile, stderr=my_logfile)
result = process.wait ()
So the make command will launch another application to be tested and I'm interested in the resulting output which is captured in a log file.
That works well except if the started application spawns its own processes, too. In this case, the output of these new processes does not appear in my log file but right in the DOS shell the python script above is started from instead.
Is there a way to get the output of these "sub sub" processes, too ?
What I have already tried (but did not work):
- Redefining
sys.stdout
andsys.stderr
by my own listener. - All kinds of
'2>&1'
redirections. - Various experiments with subprocess arguments (stdout via PIPE, shell=True, ...)
The only hint in this direction I found is Capture standard output for Python child spawned by external package, but this relates to Python subprocess applications (my launched application is in C++).