diff options
| author | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-22 06:14:02 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-22 06:14:02 +0200 |
| commit | f59dec995d909d7f32c0cb8422e1554a82e2657d (patch) | |
| tree | 731b7f691decfc413f38b97d46c0e2b53bd35ab4 /apt/progress.py | |
| parent | 0b0b062b72b721e5f5b3387b6c0fb4de6f6a4e61 (diff) | |
| parent | a39a102e437702e7cd1c3f314e507d6b0d466eb5 (diff) | |
| download | python-apt-f59dec995d909d7f32c0cb8422e1554a82e2657d.tar.gz | |
Merge local dpkg installation from the gdebi branch.
Diffstat (limited to 'apt/progress.py')
| -rw-r--r-- | apt/progress.py | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/apt/progress.py b/apt/progress.py index bb1bce35..2ef100a8 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -214,7 +214,7 @@ class InstallProgress(DumbInstallProgress): if pid == 0: # child res = pm.DoInstall(self.writefd) - os._exit(res) + os.exit(res) self.child_pid = pid res = self.waitChild() return res @@ -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(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 |
