I'm using the VTE module in a GTK window, to run and show the result of a bash script.
adresse = self.champ.get_text()
pid = self.v.fork_command(None, ['/bin/bash', "./pluzz.sh", adresse])
if pid == None: #pseudocode
print "Finish"
The child process is blocking (don't run) if there's time.sleep, or a loop. How can I do ? Thanks
Edit: Tried this:
def check_pid(pid):
""" Check For the existence of a unix pid. """
try:
os.kill(pid, 0)
except OSError:
return False
else:
return True
The problem is the return is once True, and if I write a loop, the bash script is blocking.
I've found a solution:
def __init__(self):
a=0
self.fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL)
[...]
self.v = vte.Terminal()
# self.v.connect ("child-exited", lambda term: gtk.main_quit()) # this is the line to change
self.v.connect ("child-exited", lambda term: self.copie(self, a)) # the redirection after the process is finish
self.v.show()
def download(self, a, donnees=None):
child_pid = self.v.fork_command(None, ['/bin/bash', "./pluzz.sh", adresse])
def copie(self, a, donnees=None):
print "FINISH"