Bou Baris wrote:
>> Instead of using select() use gobject.io_add_watch() on proc.stdout to
>> register a callback function that is used to read the % and set the progress
>> bar.
>>     
>
> I've modified my code to test gobject.io_add_watch()
> I expect that test_io_watch() print in console line readed from proc.stdout
> But i see nothing: look like a blocking behaviour (as when use Popen
> without use select)
> If I stop program with CTRL-C, now I see the output to console/terminal
>
>
>   def test_io_watch(self, file, condition):
>         print str(file.readline())
>         return True
>
>   def mkv_dts_extraction(self,dtstrack,pgbar=None):
>
>         command=['mkvextract', \
>                     'tracks', \
>                     self.INPUTFILE, \
>                     dtstrack + ':' + self.TEMP_DTSFILENAME]
>
>         proc=subprocess.Popen(command,stdout=subprocess.PIPE)
>
>         outfile=proc.stdout
>         outfd=outfile.fileno()
>         file_flags = fcntl.fcntl(outfd, fcntl.F_GETFL)
>         fcntl.fcntl(outfd, fcntl.F_SETFL, file_flags | os.O_NDELAY)
>
>         gobject.io_add_watch(proc.stdout,gobject.IO_IN |
> gobject.IO_HUP,self.test_io_watch)
>
>         err = proc.wait()
>
>         return True
> _______________________________________________
>   
Also I forgot you must use file.read() instead of file.readline() in 
your callback since you need to read all the available input in the 
callback.

John
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to