From 972bf036a69f3f41ae5709568e246529b8e40ba5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 17 Feb 2010 16:45:03 +0100 Subject: * apt/cache.py: - call install_progress.startUpdate()/finishUpdate() to keep compatibility with older code * apt/progress/base.py: - restore "self.statusfd, self.writefd" type, provide additional self.status_pipe and self.write_pipe file like objects --- apt/cache.py | 9 +++++---- apt/progress/base.py | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'apt') diff --git a/apt/cache.py b/apt/cache.py index 24d63361..b5733d98 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -328,15 +328,16 @@ class Cache(object): The second parameter *install_progress* refers to an InstallProgress() object of the module apt.progress. """ + # compat with older API try: - install_progress.start_update() - except AttributeError: install_progress.startUpdate() + except AttributeError: + install_progress.start_update() res = install_progress.run(pm) try: - install_progress.finish_update() - except AttributeError: install_progress.finishUpdate() + except AttributeError: + install_progress.finish_update() return res @deprecated_args diff --git a/apt/progress/base.py b/apt/progress/base.py index 6636cccc..ccf618f9 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -139,9 +139,9 @@ class InstallProgress(object): percent, select_timeout, status = 0.0, 0.1, "" def __init__(self): - (read, write) = os.pipe() - self.writefd = os.fdopen(write, "w") - self.statusfd = os.fdopen(read, "r") + (self.statusfd, self.writefd) = os.pipe() + self.write_pipe = os.fdopen(self.writefd, "w") + self.status_pipe = os.fdopen(self.statusfd, "r") fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK) def start_update(self): @@ -190,10 +190,10 @@ class InstallProgress(object): # and the execution continues in the # parent code leading to very confusing bugs try: - os._exit(obj.do_install(self.writefd.fileno())) + os._exit(obj.do_install(self.write_pipe.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", - str(self.writefd.fileno()), "-i", obj)) + str(self.write_pipe.fileno()), "-i", obj)) except Exception: os._exit(apt_pkg.PackageManager.RESULT_FAILED) @@ -208,7 +208,7 @@ class InstallProgress(object): def update_interface(self): """Update the interface.""" try: - line = self.statusfd.readline() + line = self.status_pipe.readline() except IOError, err: # resource temporarly unavailable is ignored if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK: @@ -263,7 +263,7 @@ class InstallProgress(object): (pid, res) = (0, 0) while True: try: - select.select([self.statusfd], [], [], self.select_timeout) + select.select([self.status_pipe], [], [], self.select_timeout) except select.error, (errno_, errstr): if errno_ != errno.EINTR: raise -- cgit v1.2.3