summaryrefslogtreecommitdiff
path: root/apt/progress/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'apt/progress/base.py')
-rw-r--r--apt/progress/base.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/apt/progress/base.py b/apt/progress/base.py
index 6636cccc..8075f790 100644
--- a/apt/progress/base.py
+++ b/apt/progress/base.py
@@ -28,6 +28,7 @@ import re
import select
import apt_pkg
+from apt.deprecation import function_deprecated_by
__all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress']
@@ -139,9 +140,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_stream = os.fdopen(self.writefd, "w")
+ self.status_stream = os.fdopen(self.statusfd, "r")
fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK)
def start_update(self):
@@ -158,6 +159,9 @@ class InstallProgress(object):
def status_change(self, pkg, percent, status):
"""(Abstract) Called when the APT status changed."""
+ # compat with 0.7
+ if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"):
+ self.statusChange(pkg, percent, status)
def dpkg_status_change(self, pkg, status):
"""(Abstract) Called when the dpkg status changed."""
@@ -190,10 +194,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_stream.fileno()))
except AttributeError:
os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd",
- str(self.writefd.fileno()), "-i", obj))
+ str(self.write_stream.fileno()), "-i", obj))
except Exception:
os._exit(apt_pkg.PackageManager.RESULT_FAILED)
@@ -208,7 +212,7 @@ class InstallProgress(object):
def update_interface(self):
"""Update the interface."""
try:
- line = self.statusfd.readline()
+ line = self.status_stream.readline()
except IOError, err:
# resource temporarly unavailable is ignored
if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK:
@@ -222,7 +226,6 @@ class InstallProgress(object):
(status, pkgname, percent, status_str) = line.split(":", 3)
except ValueError:
# silently ignore lines that can't be parsed
- self.read = ""
return
elif line.startswith('status'):
try:
@@ -263,7 +266,7 @@ class InstallProgress(object):
(pid, res) = (0, 0)
while True:
try:
- select.select([self.statusfd], [], [], self.select_timeout)
+ select.select([self.status_stream], [], [], self.select_timeout)
except select.error, (errno_, errstr):
if errno_ != errno.EINTR:
raise