piping question

Biggmatt matt at biggmatt.com
Mon Apr 17 14:59:42 EDT 2006


I have been working on a little frontend for newspost. It runs
newspost just fine and gets it's output. The problem is that i want it to
get the stdout as the program runs, not hold it all till it's
finished. I've tried a few variations of popen , and others with no luck.

Here is the subroutine that executes newspost:

def on_BT_go_clicked(self,obj):
        self.notebook.set_current_page(3)
        newspost = "newspost -i " + self.newsserver.get_text() + " "
        newspost += "-z " + self.port.get_text() + " "
        if self.username.get_text() != "":
           newspost += "-u " + self.username.get_text() + " "     
        if self.password.get_text() != "":
           newspost += "-p " + self.password.get_text() + " "        
        newspost += "-f " + self.email.get_text() + " "
        newspost += "-n " + self.newsgroup.get_text() + " "
        newspost += "-s \"" + self.subject.get_text() + "\" "
        if self.include_file_x_of_y.get_active():
           newspost += "-q "
        if self.yenc.get_active():
           newspost += "-y "
        for row in self.listmodel:
             newspost += "\"" + row[0] + "\" "   
         
        pipe = os.popen(newspost)
        while 1:
              output = pipe.read()
              if not(output):
                 break
              textiter = self.textbuffer.get_end_iter()
              self.textbuffer.insert(textiter, output)
        pipe.close()






More information about the Python-list mailing list