On Feb 1, 2015 4:06 PM, "Paul Moore" firstname.lastname@example.org wrote:
On 1 February 2015 at 16:29, Wes Turner email@example.com wrote:
The thing I've ended up needing to do once or twice, which is unreasonably hard with subprocess, is to run the command and capture the output, but *still* write it to stdout/stderr. So the user gets to see the command's progress, but you can introspect the results afterwards.
The hard bit is to do this while still displaying the output as it arrives. You basically need to manage the stdout and stderr pipes yourself, do nasty multi-stream interleaving, and deal with the encoding/universal_newlines stuff on the captured data. In a cross-platform way :-(
I'm not sure how that's relevant. Sure, if the child buffers output there's a delay in seeing it, but that's no more an issue than it would be for display on the console.
Ah. The link on that page that I was looking for was probably "Using Redirection" #using-redirection and/or " Capturing stdout and stderr from commands" #capturing-stdout-and-stderr-from-commands