def response(box, resp): if resp == _RESPONSE_NEXT: iface = uri.get_text() if not self._sanity_check(iface): return self.window.set_sensitive(False) self.set_keep_above(False) import subprocess child = subprocess.Popen( ['0launch', '--gui', '--download-only', '--', iface], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) errors = [''] def output_ready(src, cond): got = os.read(src.fileno(), 100) if got: errors[0] += got else: status = child.wait() self.window.set_sensitive(True) self.set_keep_above(True) if status == 0: update_details_page() nb.next_page() dialog_next.set_property('visible', False) dialog_ok.set_property('visible', True) dialog_ok.grab_focus() else: box = gtk.MessageDialog( self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _('Failed to run 0launch.\n') + errors[0]) box.run() box.destroy() return False return True gobject.io_add_watch(child.stdout, gobject.IO_IN | gobject.IO_HUP, output_ready) elif resp == gtk.RESPONSE_OK: finish() elif resp == _RESPONSE_PREV: dialog_next.set_property('visible', True) dialog_ok.set_property('visible', False) dialog_next.grab_focus() nb.prev_page() self.window.set_response_sensitive(_RESPONSE_PREV, False) else: box.destroy()
def response(box, resp): if resp == _RESPONSE_NEXT: iface = uri.get_text() if not self._sanity_check(iface): return self.window.set_sensitive(False) self.set_keep_above(False) import subprocess child = subprocess.Popen(['0launch', '--gui', '--download-only', '--', iface], stdout = subprocess.PIPE, stderr = subprocess.STDOUT) errors = [b''] def output_ready(src, cond): got = os.read(src.fileno(), 100) if got: errors[0] += got else: status = child.wait() self.window.set_sensitive(True) self.set_keep_above(True) if status == 0: update_details_page() nb.next_page() dialog_next.set_property('visible', False) dialog_ok.set_property('visible', True) dialog_ok.grab_focus() else: box = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _('Failed to run 0launch.\n') + errors[0].decode('utf-8')) box.run() box.destroy() return False return True gobject.io_add_watch(child.stdout, gobject.IO_IN | gobject.IO_HUP, output_ready) elif resp == gtk.RESPONSE_OK: finish() elif resp == _RESPONSE_PREV: dialog_next.set_property('visible', True) dialog_ok.set_property('visible', False) dialog_next.grab_focus() nb.prev_page() self.window.set_response_sensitive(_RESPONSE_PREV, False) else: box.destroy()
def run(self, command, success, get_stdout=False): assert self.child is None self.success = success if get_stdout: self.child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) gobject.io_add_watch(self.child.stdout, gobject.IO_IN | gobject.IO_HUP, self.got_stdout) gobject.io_add_watch(self.child.stderr, gobject.IO_IN | gobject.IO_HUP, self.got_errors) self.watched_streams = 2 else: self.child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) gobject.io_add_watch(self.child.stdout, gobject.IO_IN | gobject.IO_HUP, self.got_errors) self.watched_streams = 1
def run(self, command, success, get_stdout = False): assert self.child is None self.success = success if get_stdout: self.child = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE) gobject.io_add_watch(self.child.stdout, gobject.IO_IN | gobject.IO_HUP, self.got_stdout) gobject.io_add_watch(self.child.stderr, gobject.IO_IN | gobject.IO_HUP, self.got_errors) self.watched_streams = 2 else: self.child = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) gobject.io_add_watch(self.child.stdout, gobject.IO_IN | gobject.IO_HUP, self.got_errors) self.watched_streams = 1
def add_task(self, task): Blocker.add_task(self, task) if self._tag is None: self._tag = gobject.io_add_watch(self._stream, gobject.IO_OUT | gobject.IO_HUP, _io_callback, self)