[Tutor] modified readline()???

Michael Janssen mi.janssen at gmail.com
Tue Oct 19 13:48:34 CEST 2004


On Tue, 19 Oct 2004 00:51:51 -0500, Hugo González Monteverde
<hugonz-lists at h-lab.net> wrote:

> filep = popen ("/mypath/cdrecord yabba yabba yabba")

> while True:
>         can_line = filep.readline()
>         #here I'd look for the XX% string in the output, regexp or something
>         if percentage == "100%":
>                 break
> 
> But the program just puts some kind of terminal control between status
> lines. Can I redefine the "CR" in readline() as to read up to that
> character??? I cannot simply use read() and block with some buffer size
> since that does not guarante I'm getting the whole "50%" string so that
> I can parse it.... I could be getting just 5 in one pass, and then 0%
> in the next....

read one char at a time and stop reading when you found the stop
character. Meanwhile store the read chars somewhere.

Michael


More information about the Tutor mailing list