summaryrefslogtreecommitdiff
path: root/apt/progress.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2008-12-15 14:35:29 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2008-12-15 14:35:29 +0100
commitdc5fde8efcbe2054db5afb61ac0a33849a72c4d1 (patch)
tree48437e7f0214012838d8d0197b34502adb672572 /apt/progress.py
parent676d6f2735b23fc0ca7360cef0ca325ce53d8c49 (diff)
parent481a90a820564dc12567348c16773e15cc129560 (diff)
downloadpython-apt-dc5fde8efcbe2054db5afb61ac0a33849a72c4d1.tar.gz
Merged python-apt consolidation branch by Sebastian
Heinlein (many thanks): * apt/cache.py: - new method "isVirtualPackage()" - new method "getProvidingPackages()" - new method "getRequiredDownload()" - new method "additionalRequiredSpace()" * apt/debfile.py: - move a lot of the gdebi code into this file, this provides interfaces for querrying and installing .deb files and .dsc files * apt/package.py: - better description parsing - new method "installedFiles()" - new method "getChangelog()" * apt/gtk/widgets.py: - new gobject GOpProgress - new gobject GFetchProgress - new gobject GInstallProgress - new gobject GDpkgInstallProgress - new widget GtkAptProgress * doc/examples/gui-inst.py: - updated to use the new widgets * debian/control: - add suggests for python-gtk2 and python-vte * setup.py: - build html/ help of the apt and aptsources modules into /usr/share/doc/python-apt/html * data/templates/Ubuntu.info.in: - updated to fix ports.ubuntu.com for powerpc and lpia (LP: #220890) * aptsources/distro.py: - add parameter to get_distro() to make unit testing easier * tests/test_aptsources_ports.py: - add test for arch specific handling (when sub arch is on a different mirror than "main" arches) * python/acquire.cc (GetPkgAcqFile): Support DestDir and DestFilename.
Diffstat (limited to 'apt/progress.py')
-rw-r--r--apt/progress.py58
1 files changed, 56 insertions, 2 deletions
diff --git a/apt/progress.py b/apt/progress.py
index bb1bce35..a8ab76b6 100644
--- a/apt/progress.py
+++ b/apt/progress.py
@@ -208,7 +208,7 @@ class InstallProgress(DumbInstallProgress):
(pid, res) = os.waitpid(self.child_pid,os.WNOHANG)
if pid == self.child_pid:
break
- return os.WEXITSTATUS(res)
+ return res
def run(self, pm):
pid = self.fork()
if pid == 0:
@@ -217,7 +217,7 @@ class InstallProgress(DumbInstallProgress):
os._exit(res)
self.child_pid = pid
res = self.waitChild()
- return res
+ return os.WEXITSTATUS(res)
class CdromProgress:
""" Report the cdrom add progress
@@ -233,6 +233,60 @@ class CdromProgress:
def changeCdrom(self):
pass
+
+class DpkgInstallProgress(InstallProgress):
+ """
+ Progress handler for a local Debian package installation
+ """
+ def run(self, debfile):
+ """
+ Start installing the given Debian package
+ """
+ self.debfile = debfile
+ self.debname = os.path.basename(debfile).split("_")[0]
+ pid = self.fork()
+ if pid == 0:
+ # child
+ res = os.system("/usr/bin/dpkg --status-fd %s -i %s" % \
+ (self.writefd, self.debfile))
+ os._exit(os.WEXITSTATUS(res))
+ self.child_pid = pid
+ res = self.waitChild()
+ return res
+
+ def updateInterface(self):
+ """
+ Process status messages from dpkg
+ """
+ if self.statusfd != None:
+ while True:
+ try:
+ self.read += os.read(self.statusfd.fileno(),1)
+ except OSError, (errno,errstr):
+ # resource temporarly unavailable is ignored
+ if errno != 11:
+ print errstr
+ break
+ if self.read.endswith("\n"):
+ statusl = string.split(self.read, ":")
+ if len(statusl) < 3:
+ print "got garbage from dpkg: '%s'" % read
+ self.read = ""
+ break
+ status = statusl[2].strip()
+ #print status
+ if status == "error":
+ self.error(self.debname, status)
+ elif status == "conffile-prompt":
+ # we get a string like this:
+ # 'current-conffile' 'new-conffile' useredited distedited
+ match = re.compile("\s*\'(.*)\'\s*\'(.*)\'.*").match(status_str)
+ if match:
+ self.conffile(match.group(1), match.group(2))
+ else:
+ self.status = status
+ self.read = ""
+
# module test code
if __name__ == "__main__":
import apt_pkg