summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-12-07 11:22:30 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-12-07 11:22:30 +0000
commita7073554674b0e9aaf262e4d981fbbb20713ac4a (patch)
tree429fbfb7b44cdf908e1a103501032793ed86e44d
parentcce2b71c2fd64c8587238178c27a049ec450ce07 (diff)
downloadpython-apt-a7073554674b0e9aaf262e4d981fbbb20713ac4a.tar.gz
* InstallProgress.{error,conffile}() functions added
-rw-r--r--apt/progress.py18
-rw-r--r--doc/examples/inst.py9
2 files changed, 24 insertions, 3 deletions
diff --git a/apt/progress.py b/apt/progress.py
index b02fb33a..3ebe3664 100644
--- a/apt/progress.py
+++ b/apt/progress.py
@@ -19,7 +19,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
-import sys, apt_pkg, os, fcntl, string
+import sys, apt_pkg, os, fcntl, string, re
class OpProgress:
""" Abstract class to implement reporting on cache opening
@@ -145,6 +145,12 @@ class InstallProgress(DumbInstallProgress):
self.read = ""
self.percent = 0.0
self.status = ""
+ def error(self, pkg, errormsg):
+ " called when a error is detected during the install "
+ pass
+ def conffile(self,current,new):
+ " called when a conffile question from dpkg is detected "
+ pass
def updateInterface(self):
if self.statusfd != None:
try:
@@ -154,14 +160,22 @@ class InstallProgress(DumbInstallProgress):
if errno != 11:
print errstr
if self.read.endswith("\n"):
- # FIXME: add errorhandling
s = self.read
#print s
(status, pkg, percent, status_str) = string.split(s, ":")
#print "percent: %s %s" % (pkg, float(percent)/100.0)
+ if status == "pmerror":
+ self.error(pkg,status_str)
+ elif status == "pmconffile":
+ # 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))
self.percent = float(percent)
self.status = string.strip(status_str)
self.read = ""
+
def fork(self):
return os.fork()
def waitChild(self):
diff --git a/doc/examples/inst.py b/doc/examples/inst.py
index 66b61c54..0e91c28f 100644
--- a/doc/examples/inst.py
+++ b/doc/examples/inst.py
@@ -19,13 +19,20 @@ class TextInstallProgress(InstallProgress):
sys.stdout.write("\r[%s] %s\n" %(self.percent, self.status))
sys.stdout.flush()
self.last = self.percent
+ def conffile(self,current,new):
+ print "conffile prompt: %s %s" % (current,new)
+ def error(self, errorstr):
+ print "got dpkg error: '%s'" % errorstr
cache = apt.Cache(apt.progress.OpTextProgress())
fprogress = apt.progress.TextFetchProgress()
iprogress = TextInstallProgress()
-pkg = cache["base-config"]
+pkg = cache["test-package"]
+pkg.markUpgrade()
+cache.commit(fprogress,iprogress)
+sys.exit(1)
# install or remove, the importend thing is to keep us busy :)
if pkg.isInstalled: