piping question

B

Biggmatt

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()
 
S

Steve Bergman

Have you tried running python with '-u'? That turns off most buffering
within python at least. I'm not familiar with newspost, so I've no
idea what to do about any output buffering it might be doing.
 
L

Lawrence D'Oliveiro

Biggmatt said:
The problem is that i want it to
get the stdout as the program runs, not hold it all till it's
finished.

This has been discussed before. If the program you're trying to control
buffers its output and gives no option to disable that, then you're
stuck with the way it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top