Hallo all,

I know that my question is kind out of topic but since I use pygtk for this
small project and on this list there are people which are familiar with C I will
dare to ask.

I'm new to python and do like it. For learning purposes I decided to write a
simple GUI for mencoder using pygtk but I have a problem regarding the user
feedback. Can somebody tell me why these two programs have different output? I
mean - why python's pipe "eat up" the debugging information printed by
mencoder to stderr preventing me from presenting a nice progress bar to the user?

Many thanks and sorry for the off topic question - Velko

---

#!/usr/bin/python

import os

def main():
        f = os.popen('mencoder -dvd 1 -chapter 1-1 -ovc copy -oac copy -o delme.avi 
2>&1')
        if f == None:
                return

        line = None
        while line != '':
                line = f.readline()
                print line

        f.close()
        return
        
main()

---

#include <stdio.h>

int main(int argc, char *argv[])
{
    FILE *f = NULL;
    char buf[1024];
    size_t request = sizeof(buf);

    f = popen("mencoder -dvd 1 -chapter 1-1 -ovc copy -oac copy -o delme.avi 2>&1", 
"r");
    if(!f)
        return 1;

    while(fread(buf, request - 1, 1, f) == 1) {
        buf[request - 1] = '\0';
        fprintf(stderr, "%s\n", buf);
    }

    fprintf(stderr, "%s\n", buf);

    pclose(f);
    return 0;
}

-- 
Two computer people discussing those old stories about Bill Gates'
name adding up to 666 in ASCII:
"I hear that if you play the NT 4.0 CD backward, you get a satanic
message."
"That's nothing. If you play it forward, it installs NT 4.0."
                - Anonymous
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to