<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). &nbsp;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 = &quot;HEAD&quot;):</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; command
= &quot;cvs rdiff -s -r \&quot;%(buildFromStamp)s\&quot; -r \&quot;%(buildToStamp)s\&quot;
%(targetModule)s&quot; % locals()</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; print
&quot;Running CVS Command:&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; print
command</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; try:</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; cvsrdiffoutfile, cvsstdinfile = popen2.popen2(command)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; except
os.error:</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;CVS command failed at OS level.&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;Rdiff operation did not complete&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;Bailing...&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; sys.exit(1)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; except:</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;Unknown error occurred.&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;Rdiff operation did not complete.&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; print &quot;Bailing...&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; sys.exit(2)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; #And
return with anything we found in here</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cvsrdiffout
= cvsrdiffoutfile.readlines()</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; 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(&quot;MODULE_NAME&quot;,
&quot;TAG&quot;)</font>
<br>
<br><font size=2 face="sans-serif">never returns. &nbsp;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. &nbsp;It looks like popen2 isn't waiting for the command to complete,
and I don't know how to make it do that. &nbsp;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. &nbsp;Any help? &nbsp;Thanks in advance,</font>
<br>
<br><font size=2 face="sans-serif">-Cs</font>