From 8572d7a6dff1c3b5e8b27fcfbc36bd13232be598 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 12:28:50 +0200 Subject: * debian/control: - tightend dependency * apt/progress.py: - use os._exit() instead of sys.exit() (lp: 53298) --- apt/progress.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apt/progress.py') diff --git a/apt/progress.py b/apt/progress.py index 4119067c..d69ca6e6 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -19,7 +19,12 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import sys, apt_pkg, os, fcntl, string, re +import sys +import os +import re +import fcntl +import string +import apt_pkg class OpProgress(object): """ Abstract class to implement reporting on cache opening @@ -199,7 +204,7 @@ class InstallProgress(DumbInstallProgress): if pid == 0: # child res = pm.DoInstall(self.writefd) - sys.exit(res) + os._exit(res) self.child_pid = pid res = self.waitChild() return res -- cgit v1.2.3 From 7035132c76acf5fd72e62437e487f411bf726d5c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 15:16:33 +0200 Subject: * apt/progress.py: - use select() when waiting for child input --- apt/progress.py | 9 ++++++--- debian/changelog | 1 + doc/examples/inst.py | 5 +---- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'apt/progress.py') diff --git a/apt/progress.py b/apt/progress.py index d69ca6e6..8ac0e1dc 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -24,6 +24,8 @@ import os import re import fcntl import string +from errno import * +import select import apt_pkg class OpProgress(object): @@ -144,6 +146,7 @@ class InstallProgress(DumbInstallProgress): """ def __init__(self): DumbInstallProgress.__init__(self) + self.selectTimeout = 0.1 (read, write) = os.pipe() self.writefd=write self.statusfd = os.fdopen(read, "r") @@ -167,7 +170,7 @@ class InstallProgress(DumbInstallProgress): self.read += os.read(self.statusfd.fileno(),1) except OSError, (errno,errstr): # resource temporarly unavailable is ignored - if errno != 11: + if errno != EAGAIN and errnor != EWOULDBLOCK: print errstr if self.read.endswith("\n"): s = self.read @@ -189,15 +192,15 @@ class InstallProgress(DumbInstallProgress): self.percent = float(percent) self.status = string.strip(status_str) self.read = "" - def fork(self): return os.fork() def waitChild(self): while True: + select.select([self.statusfd],[],[], self.selectTimeout) + self.updateInterface() (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) if pid == self.child_pid: break - self.updateInterface() return os.WEXITSTATUS(res) def run(self, pm): pid = self.fork() diff --git a/debian/changelog b/debian/changelog index 5f8db68b..02ec00a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ python-apt (0.6.20) unstable; urgency=low - tightend dependency (closes: #383478) * apt/progress.py: - use os._exit() in the child (lp: #53298) + - use select() when checking for statusfd (lp: #53282) -- diff --git a/doc/examples/inst.py b/doc/examples/inst.py index 0e91c28f..ff9d452c 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -29,10 +29,7 @@ cache = apt.Cache(apt.progress.OpTextProgress()) fprogress = apt.progress.TextFetchProgress() iprogress = TextInstallProgress() -pkg = cache["test-package"] -pkg.markUpgrade() -cache.commit(fprogress,iprogress) -sys.exit(1) +pkg = cache["3dchess"] # install or remove, the importend thing is to keep us busy :) if pkg.isInstalled: -- cgit v1.2.3 From 4ae6dbf9a654189b1f07e8056fff9a3b877a6e2d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 3 Nov 2006 22:04:49 +0100 Subject: * apt/progress.py: - protect against unparsable strings send from dpkg --- apt/progress.py | 7 ++++++- debian/changelog | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'apt/progress.py') diff --git a/apt/progress.py b/apt/progress.py index 8ac0e1dc..5169adf7 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -175,7 +175,12 @@ class InstallProgress(DumbInstallProgress): if self.read.endswith("\n"): s = self.read #print s - (status, pkg, percent, status_str) = string.split(s, ":") + try: + (status, pkg, percent, status_str) = string.split(s, ":",3) + except ValueError, e: + # silently ignore lines that can't be parsed + self.read = "" + return #print "percent: %s %s" % (pkg, float(percent)/100.0) if status == "pmerror": self.error(pkg,status_str) diff --git a/debian/changelog b/debian/changelog index 0dfa9381..9451428c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ python-apt (0.6.21) unstable; urgency=low instead. This fixes a nasty segfault with python2.5 (lp: 63226) * debian/rules: Remove dh_python call. + * protect against not-parsable strings send from dpkg (lp: 68553) -- -- cgit v1.2.3