I've built a command-line build system based on the Python-based tool Scons. Since all the workstations running Scons have to have Python installed, I'd prefer to just do the few driver scripts I need at the top in Python also.
I have been just using
os.system
during development, but I now have the system ready to go into daily build use and would like to write
results to a log file. I specifically failed trying the 'subprocess' module. I couldn't get it work below one
level when redirecting the stdout and stderr. That is:
import subprocess
bldcommand = 'bld.py'
one = open("stdout.out","w")
two = open("stderr.err","w")
subprocess.call(bldcommand
,stdout=on
e,stderr=t
wo,shell=T
rue)
This runs the underlying 'bld.py' command, but fails to run its underlying call to scons, whether done
with 'os.system' or 'subprocess', without its own I/O redirection. If I remove the I/O redirection clauses
in the call above, the 'bld.py' script runs correctly, but of course without I/O redirection at all.
This is all under Windows, by company mandate ... any suggestions would be most appreciated.
Start Free Trial