summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-17 16:45:03 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-17 16:45:03 +0100
commit972bf036a69f3f41ae5709568e246529b8e40ba5 (patch)
tree7e1ea3b5269dc90ea4d3e0b3fe621c505140ce17 /apt
parentd1b2c0fbd34cee0ffced8270149b87def7675b2a (diff)
downloadpython-apt-972bf036a69f3f41ae5709568e246529b8e40ba5.tar.gz
* 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
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py9
-rw-r--r--apt/progress/base.py14
2 files changed, 12 insertions, 11 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..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