<br><font size=2 face="sans-serif">Hi there - </font>
<br>
<br><font size=2 face="sans-serif">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</font>
<br>
<br><font size=2 face="sans-serif">Defining the function:</font>
<br>
<br><font size=2 face="sans-serif">def rdiffApp (targetModule, buildFromStamp,
buildToStamp = "HEAD"):</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> command
= "cvs rdiff -s -r \"%(buildFromStamp)s\" -r \"%(buildToStamp)s\"
%(targetModule)s" % locals()</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> print
"Running CVS Command:"</font>
<br><font size=2 face="sans-serif"> print
command</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> try:</font>
<br><font size=2 face="sans-serif">
cvsrdiffoutfile, cvsstdinfile = popen2.popen2(command)</font>
<br><font size=2 face="sans-serif"> except
os.error:</font>
<br><font size=2 face="sans-serif">
print "CVS command failed at OS level."</font>
<br><font size=2 face="sans-serif">
print "Rdiff operation did not complete"</font>
<br><font size=2 face="sans-serif">
print "Bailing..."</font>
<br><font size=2 face="sans-serif">
sys.exit(1)</font>
<br><font size=2 face="sans-serif"> except:</font>
<br><font size=2 face="sans-serif">
print "Unknown error occurred."</font>
<br><font size=2 face="sans-serif">
print "Rdiff operation did not complete."</font>
<br><font size=2 face="sans-serif">
print "Bailing..."</font>
<br><font size=2 face="sans-serif">
sys.exit(2)</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> #And
return with anything we found in here</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif"> cvsrdiffout
= cvsrdiffoutfile.readlines()</font>
<br><font size=2 face="sans-serif"> return
cvsrdiffout</font>
<br>
<br>
<br><font size=2 face="sans-serif">And then running the following line:</font>
<br>
<br><font size=2 face="sans-serif">cvs = rdiffApp("MODULE_NAME",
"TAG")</font>
<br>
<br><font size=2 face="sans-serif">never returns. In fact, it hangs
the interpreter, and I have to kill the window to try again. </font>
<br>
<br><font size=2 face="sans-serif">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 advance,</font>
<br>
<br><font size=2 face="sans-serif">-Cs</font>