summaryrefslogtreecommitdiff
path: root/apt/progress.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2008-11-24 14:46:48 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2008-11-24 14:46:48 +0100
commit59937b2d3b6319773ab174066222c81ecd176628 (patch)
tree10863dc97ff1d44e9b4732896d03eb0f3257004f /apt/progress.py
parentb90575e96622f14dc3d25972d0498faf0a02259e (diff)
parentd7b8902c36f77b7ae87b88cb4fdfbba7aa2ff833 (diff)
downloadpython-apt-59937b2d3b6319773ab174066222c81ecd176628.tar.gz
merged from the consolidation-bracn (with some modificatins)
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