real time updating of popen, bufsize=0 problems
Rob Wolfe
rw at smsnet.pl
Fri Apr 6 15:59:26 EDT 2007
"ianaré" <ianare at gmail.com> writes:
> hey all, I'm trying to get real time updates of batch file output.
[...]
> So I tried subprocess:
> proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0,
> stdout=subprocess.PIPE)
Instead of that:
> for line in proc.stdout:
> self.display.WriteText(line)
try that:
while True:
line = proc.stdout.readline()
if not line: break
self.display.WriteText(line)
When a file is used in a for loop it works like an iterator.
You can read details here (description of method ``next``):
http://docs.python.org/lib/bltin-file-objects.html
--
HTH,
Rob
More information about the Python-list
mailing list