[Tutor] Process control and capturing output
Connor.Smith at huntington.com
Wed Jun 1 21:16:36 CEST 2005
Hi there -
I'm trying to capture the output of a long-running command in the
background (it's a CVS rdiff on a fairly big repository). I need to
capture the stdout from this command, and then parse it later for a report
Defining the function:
def rdiffApp (targetModule, buildFromStamp, buildToStamp = "HEAD"):
command = "cvs rdiff -s -r \"%(buildFromStamp)s\" -r
\"%(buildToStamp)s\" %(targetModule)s" % locals()
print "Running CVS Command:"
cvsrdiffoutfile, cvsstdinfile = popen2.popen2(command)
print "CVS command failed at OS level."
print "Rdiff operation did not complete"
print "Unknown error occurred."
print "Rdiff operation did not complete."
#And return with anything we found in here
cvsrdiffout = cvsrdiffoutfile.readlines()
And then running the following line:
cvs = rdiffApp("MODULE_NAME", "TAG")
never returns. In fact, it hangs the interpreter, and I have to kill the
window to try again.
I'm running Python 2.4 on a Windows 2000 box. It looks like popen2 isn't
waiting for the command to complete, and I don't know how to make it do
that. An easy solution to this would be to write the stdout file to disk,
and then read it later, but I'd rather not write temp files to disk, if I
can keep them in a file-like object in memory. Any help? Thanks in
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor