diff options
Diffstat (limited to 'apt/progress')
| -rw-r--r-- | apt/progress/base.py | 5 | ||||
| -rw-r--r-- | apt/progress/gtk2.py | 12 |
2 files changed, 9 insertions, 8 deletions
diff --git a/apt/progress/base.py b/apt/progress/base.py index 97375431..ab57dd82 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -27,6 +27,7 @@ import fcntl import os import re import select +import sys import apt_pkg @@ -141,6 +142,7 @@ class InstallProgress(object): def __init__(self): (self.statusfd, self.writefd) = os.pipe() + # These will leak fds, but fixing this safely requires API changes. self.write_stream = os.fdopen(self.writefd, "w") self.status_stream = os.fdopen(self.statusfd, "r") fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK) @@ -196,7 +198,8 @@ class InstallProgress(object): os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.write_stream.fileno()), "-i", obj)) - except Exception: + except Exception as e: + sys.stderr.write("%s\n" % e) os._exit(apt_pkg.PackageManager.RESULT_FAILED) self.child_pid = pid diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index 9137ef76..c2635ca0 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -22,9 +22,6 @@ # USA """GObject-powered progress classes and a GTK+ status widget.""" -import os -import time - import pygtk pygtk.require('2.0') import gtk @@ -34,6 +31,7 @@ except ImportError: import gobject as glib import gobject import pango +import time import vte import apt_pkg @@ -127,16 +125,15 @@ class GInstallProgress(gobject.GObject, base.InstallProgress): self.apt_status = -1 self.time_last_update = time.time() self.term = term - reaper = vte.reaper_get() - reaper.connect("child-exited", self.child_exited) + self.term.connect("child-exited", self.child_exited) self.env = ["VTE_PTY_KEEP_FD=%s" % self.writefd, "DEBIAN_FRONTEND=gnome", "APT_LISTCHANGES_FRONTEND=gtk"] self._context = glib.main_context_default() - def child_exited(self, term, pid, status): + def child_exited(self, term): """Called when a child process exits""" - self.apt_status = os.WEXITSTATUS(status) + self.apt_status = term.get_child_exit_status() self.finished = True def error(self, pkg, errormsg): @@ -204,6 +201,7 @@ class GInstallProgress(gobject.GObject, base.InstallProgress): """Wait for the child process to exit.""" while not self.finished: self.update_interface() + time.sleep(0.02) return self.apt_status if apt_pkg._COMPAT_0_7: |
