summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-02-27 13:27:54 +0100
committerJulian Andres Klode <jak@debian.org>2010-02-27 13:27:54 +0100
commit83521b397a31165de60ad50fe73e684290c52a43 (patch)
treea5b8947695c6a0f69211dd1eb9377d16d936147c /apt
parent930f6a2899b0b410777397fb206a8eba8c99100c (diff)
parente5237896629a9fc7ba123b6248eff19d6440cf19 (diff)
downloadpython-apt-83521b397a31165de60ad50fe73e684290c52a43.tar.gz
Merge the mvo branch
[ Michael Vogt ] * 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_stream and self.write_stream file like objects * python/progress.cc: - try to call compatibility functions first, then new functions
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py9
-rw-r--r--apt/progress/base.py19
-rw-r--r--apt/progress/old.py1
3 files changed, 17 insertions, 12 deletions
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..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
diff --git a/apt/progress/old.py b/apt/progress/old.py
index c2d95b85..15ead890 100644
--- a/apt/progress/old.py
+++ b/apt/progress/old.py
@@ -191,6 +191,7 @@ class InstallProgress(DumbInstallProgress, base.InstallProgress):
selectTimeout = AttributeDeprecatedBy('select_timeout')
statusChange = function_deprecated_by(base.InstallProgress.status_change)
+ updateInterface = function_deprecated_by(base.InstallProgress.update_interface)
waitChild = function_deprecated_by(base.InstallProgress.wait_child)