You are not logged in.
Hi,
I'm having a problem with a python program I'm currently working on.
It's starting an application (mplayer) as a subprocess.Popen object. I don't want to have the (stdout-)output on the screen and I want to be able to search it for patterns. The thing is that the output is a potentially neverending stream of data. How would I best do that?
If I'm directing the processes stdout to subprocess.PIPE, I can't seem to read it's contents, because it doesn't come to an end. If I direct it into a file everything is fine, but that file keeps growing and growing, which is obviously very bad style. What I'd need is some kind of buffer with a static size, which I can read like a file object. Does such an object exist in python? Or is there some other way to parse fixed chunks of STOUT output, I have not thought about?
thanks in advance
*edit*
There was a simple solution: where read() on the subprocess.PIPE of the running process wouldn't work, read(n) does.
Last edited by Zoranthus (2008-07-24 20:31:29)
Offline