Re: tee-like behavior in Python

2012-05-09 Thread Chris Rebert
On Wed, May 9, 2012 at 8:35 AM, Florian Lindner wrote: > Hello, > > how can I achieve a behavior like tee in Python? > > * execute an application > * leave the output to stdout and stderr untouched > * but capture both and save it to a file (resp. file-like object) > > I have this code > > proc =

Re: tee-like behavior in Python

2012-05-09 Thread Dan Stromberg
You've had some good responses already, but here're two more: 1) Easiest would be to use setvbuf in the child process, if you have access to its source. This allows you to force line-oriented buffering. 2) stdio likes to buffer to tty/pty's in a line-oriented manner, and other things in a block-

Re: tee-like behavior in Python

2012-05-09 Thread William R. Wing (Bill Wing)
On May 9, 2012, at 11:35 AM, Florian Lindner wrote: > Hello, > > how can I achieve a behavior like tee in Python? > > * execute an application > * leave the output to stdout and stderr untouched > * but capture both and save it to a file (resp. file-like object) > > I have this code > > proc =

Re: tee-like behavior in Python

2012-05-09 Thread J
On Wed, May 9, 2012 at 11:35 AM, Florian Lindner wrote: > Hello, > > how can I achieve a behavior like tee in Python? > > * execute an application > * leave the output to stdout and stderr untouched > * but capture both and save it to a file (resp. file-like object) > > I have this code > > proc =

Re: tee-like behavior in Python

2012-05-09 Thread Dave Angel
On 05/09/2012 11:35 AM, Florian Lindner wrote: > Hello, > > how can I achieve a behavior like tee in Python? > > * execute an application > * leave the output to stdout and stderr untouched > * but capture both and save it to a file (resp. file-like object) > > I have this code > > proc = subproces

tee-like behavior in Python

2012-05-09 Thread Florian Lindner
Hello, how can I achieve a behavior like tee in Python? * execute an application * leave the output to stdout and stderr untouched * but capture both and save it to a file (resp. file-like object) I have this code proc = subprocess.Popen(shlex.split(cmd), stdout = subprocess.PIPE, stderr=subpro