|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
||||
|
||||
|
getting output from command that isn't STDIN
hullo,
I need to get the output from mencoder as it encodes videos. Most of it can be retrieved easily enough, but after the initial blurb, it then displays a progress meter with various information including percentage complete, and that stays on the same line, if you get me, like wget's progress meter. That lien doesn't get picked up through STDTIN or STDERR... I only get the last time that line is refreshed (when it's done) which isn't much use. How can I grab this output? The code atm is like this: PHP Code:
|
|
#2
|
|||
|
|||
|
Sounds like it's using buffered I/O. You probably want it to be unbuffered, call os.popen (btw, I don't know why you did from os import popen or the even worse from os import * - it's considered bad Python style) like so:
Code:
pipe = os.popen(command, 'r', 0) The os.popen command takes arguments similar to the file builtin constructor. The 0 is for unbuffered I/O. |
|
#3
|
||||
|
||||
|
Hrm, that didn't work
![]() I got this from comp.lang.python: pipe = popen(command, 'r').fileno() while 1: data = os.read(pipe, 3000) if not data: break os.write(1, data) which I'm also fiddling around with ??? Last edited by telex4 : February 26th, 2003 at 06:51 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > getting output from command that isn't STDIN |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|