summaryrefslogtreecommitdiff
path: root/apt/progress
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-31 20:51:57 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-31 20:51:57 +0200
commite556b2cbbe5878c33d9e7302e637cc7f35dd14bf (patch)
treeae42303d29a2d9c0332f5560953ad4f9eb2145ee /apt/progress
parentd3832ab4faf69d8e8e0a0e14b159514505031231 (diff)
downloadpython-apt-e556b2cbbe5878c33d9e7302e637cc7f35dd14bf.tar.gz
apt/progress: Large update, introducing apt.progress.base.InstallProgress.
This contains many updates including the introduction of a new InstallProgress class which replaces the old InstallProgress and DpkgInstallProgress classes.
Diffstat (limited to 'apt/progress')
-rw-r--r--apt/progress/__init__.py13
-rw-r--r--apt/progress/base.py135
-rw-r--r--apt/progress/gtk2.py82
-rw-r--r--apt/progress/old.py294
-rw-r--r--apt/progress/text.py2
5 files changed, 223 insertions, 303 deletions
diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py
index c75c368b..10c11021 100644
--- a/apt/progress/__init__.py
+++ b/apt/progress/__init__.py
@@ -1,3 +1,5 @@
+# apt/progress/__init__.py - Initialization file for apt.progress.
+#
# Copyright (c) 2009 Julian Andres Klode <jak@debian.org>
#
# This program is free software; you can redistribute it and/or
@@ -14,9 +16,18 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
-"""Progress reporting."""
+"""Progress reporting.
+
+This package provides progress reporting for the python-apt package. The module
+'base' provides classes with no output, the module 'gtk2' provides classes for
+GTK+ applications, and the module 'text' provides classes for terminals, etc.
+"""
import apt_pkg
+
+__all__ = []
+
+
if apt_pkg._COMPAT_0_7:
from apt.progress.old import (CdromProgress, DpkgInstallProgress,
DumbInstallProgress, FetchProgress,
diff --git a/apt/progress/base.py b/apt/progress/base.py
index fc5a8107..08d35533 100644
--- a/apt/progress/base.py
+++ b/apt/progress/base.py
@@ -21,6 +21,13 @@
Custom progress classes should inherit from these classes. They can also be
used as dummy progress classes which simply do nothing.
"""
+import errno
+import fcntl
+import os
+import re
+import select
+
+__all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress']
class AcquireProgress(object):
@@ -125,23 +132,131 @@ class CdromProgress(object):
class InstallProgress(object):
- """Report the install progress.
+ """Class to report the progress of installing packages."""
- Subclass this class to implement install progress reporting.
- """
+ percent, select_timeout, status = 0.0, 0.1, ""
- def start_update(self):
- """Start update."""
+ def __init__(self):
+ (read, write) = os.pipe()
+ self.writefd = os.fdopen(write, "w")
+ self.statusfd = os.fdopen(read, "r")
+ fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK)
- def run(self, pm):
- """Start installation."""
- return pm.do_install()
+ def start_update(self):
+ """(Abstract) Start update."""
def finish_update(self):
- """Called when update has finished."""
+ """(Abstract) Called when update has finished."""
+
+ def error(self, pkg, errormsg):
+ """(Abstract) Called when a error is detected during the install."""
+
+ def conffile(self, current, new):
+ """(Abstract) Called when a conffile question from dpkg is detected."""
+
+ def status_change(self, pkg, percent, status):
+ """(Abstract) Called when the status changed."""
+
+ def processing(self, pkg, stage):
+ """(Abstract) Sent just before a processing stage starts.
+
+ The parameter 'stage' is one of "upgrade", "install"
+ (both sent before unpacking), "configure", "trigproc", "remove",
+ "purge". This method is used for dpkg only.
+ """
+
+ def run(self, obj):
+ """Install using the object 'obj'.
+
+ This functions runs install actions. The parameter 'obj' may either
+ be a PackageManager object in which case its do_install() method is
+ called or the path to a deb file.
+
+ If the object is a PackageManager, the functions returns the result
+ of calling its do_install() method. Otherwise, the function returns
+ the exit status of dpkg. In both cases, 0 means that there were no
+ problems.
+ """
+ pid = self.fork()
+ if pid == 0:
+ try:
+ os._exit(obj.do_install(self.writefd.fileno()))
+ except AttributeError:
+ os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd",
+ str(self.writefd.fileno()), "-i", obj))
+ self.child_pid = pid
+ res = self.wait_child()
+ return os.WEXITSTATUS(res)
+
+ def fork(self):
+ """Fork."""
+ return os.fork()
def update_interface(self):
- """Called periodically to update the user interface."""
+ """Update the interface."""
+ try:
+ line = self.statusfd.readline()
+ except IOError, (errno_, errstr):
+ # resource temporarly unavailable is ignored
+ if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK:
+ print errstr
+ return
+
+ pkgname = status = status_str = percent = base = ""
+
+ if line.startswith('pm'):
+ try:
+ (status, pkgname, percent, status_str) = line.split(":", 3)
+ except ValueError:
+ # silently ignore lines that can't be parsed
+ self.read = ""
+ return
+ elif line.startswith('status'):
+ try:
+ (base, pkgname, status, status_str) = line.split(": ", 3)
+ except ValueError:
+ (base, pkgname, status) = line.split(": ", 2)
+ elif line.startswith('processing'):
+ (status, status_str, pkgname) = line.split(": ", 2)
+ self.processing(pkgname.strip(), status_str.strip())
+
+ if status == 'pmerror' or status == 'error':
+ self.error(pkgname, status_str)
+ elif status == 'conffile-prompt' or status == 'pmconffile':
+ match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str)
+ if match:
+ self.conffile(match.group(1), match.group(2))
+ elif status == "pmstatus":
+ if float(percent) != self.percent or status_str != self.status:
+ self.status_change(pkgname, float(percent), status_str.strip())
+ self.percent = float(percent)
+ self.status = status_str.strip()
+
+ def wait_child(self):
+ """Wait for child progress to exit.
+
+ This method is responsible for calling update_interface() from time to
+ time. It exits once the child has exited.
+ """
+ (pid, res) = (0, 0)
+ while True:
+ try:
+ select.select([self.statusfd], [], [], self.select_timeout)
+ except select.error, err:
+ if err[0] != errno.EINTR:
+ raise
+
+ self.update_interface()
+ try:
+ (pid, res) = os.waitpid(self.child_pid, os.WNOHANG)
+ if pid == self.child_pid:
+ break
+ except OSError, err:
+ if err[0] != errno.EINTR:
+ raise
+ if err[0] == errno.ECHILD:
+ break
+ return res
class OpProgress(object):
diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py
index edba0a4d..22788984 100644
--- a/apt/progress/gtk2.py
+++ b/apt/progress/gtk2.py
@@ -11,7 +11,7 @@
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
-# his program is distributed in the hope that it will be useful,
+# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
@@ -42,6 +42,9 @@ from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy
from apt.progress import base, old
+__all__ = ['GInstallProgress', 'GOpProgress', 'GtkAptProgress']
+
+
def mksig(params=(), run=gobject.SIGNAL_RUN_FIRST, rettype=gobject.TYPE_NONE):
"""Simplified Create a gobject signal.
@@ -90,7 +93,7 @@ class GOpProgress(gobject.GObject, base.OpProgress):
Op = AttributeDeprecatedBy('op')
-class GInstallProgress(gobject.GObject, old.InstallProgress):
+class GInstallProgress(gobject.GObject, base.InstallProgress):
"""Installation progress with GObject signals.
Signals:
@@ -114,7 +117,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress):
"status-finished": mksig()}
def __init__(self, term):
- old.InstallProgress.__init__(self)
+ base.InstallProgress.__init__(self)
gobject.GObject.__init__(self)
self.finished = False
self.time_last_update = time.time()
@@ -152,6 +155,11 @@ class GInstallProgress(gobject.GObject, old.InstallProgress):
"""
self.emit("status-started")
+ def run(self, obj):
+ """Run."""
+ self.finished = False
+ return base.InstallProgress.run(self, obj)
+
def finish_update(self):
"""Called when the update finished.
@@ -159,6 +167,11 @@ class GInstallProgress(gobject.GObject, old.InstallProgress):
"""
self.emit("status-finished")
+ def processing(self, pkg, stage):
+ """Called when entering a new stage in dpkg."""
+ # We have no percentage or alike, send -1 to let the bar pulse.
+ self.emit("status-changed", ("Installing %s...") % pkg, -1)
+
def status_change(self, pkg, percent, status):
"""Called when the status changed.
@@ -172,7 +185,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress):
Emits: status-timeout() [When a timeout happens]
"""
- old.InstallProgress.update_interface(self)
+ base.InstallProgress.update_interface(self)
while self._context.pending():
self._context.iteration()
if self.time_last_update + self.INSTALL_TIMEOUT < time.time():
@@ -197,34 +210,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress):
childExited = function_deprecated_by(child_exited)
-class GDpkgInstallProgress(old.DpkgInstallProgress,
- GInstallProgress):
- """An InstallProgress for local installations.
-
- Signals:
-
- * status-changed(str: status, int: percent)
- * status-started() - Not Implemented yet
- * status-finished()
- * status-timeout() - When the maintainer script hangs
- * status-error() - When an error happens
- * status-conffile() - On Conffile
- """
-
- def run(self, debfile):
- """Install the given package."""
- old.DpkgInstallProgress.run(self, debfile)
-
- def update_interface(self):
- """Called periodically to update the interface.
-
- Emits: status-timeout() [When a timeout happens]"""
- old.DpkgInstallProgress.update_interface(self)
- if self.time_last_update + self.INSTALL_TIMEOUT < time.time():
- self.emit("status-timeout")
-
- if apt_pkg._COMPAT_0_7:
- updateInterface = function_deprecated_by(update_interface)
+GDpkgInstallProgress = GInstallProgress
class GFetchProgress(gobject.GObject, old.FetchProgress):
@@ -235,6 +221,8 @@ class GFetchProgress(gobject.GObject, old.FetchProgress):
* status-changed(str: description, int: percent)
* status-started()
* status-finished()
+
+ DEPRECATED.
"""
__gsignals__ = {"status-changed": mksig((str, int)),
@@ -258,19 +246,19 @@ class GFetchProgress(gobject.GObject, old.FetchProgress):
def pulse(self):
old.FetchProgress.pulse(self)
- current_item = self.current_items + 1
- if current_item > self.total_items:
- current_item = self.total_items
+ current_item = self.currentItems + 1
+ if current_item > self.totalItems:
+ current_item = self.totalItems
if self.current_cps > 0:
text = (_("Downloading file %(current)li of %(total)li with "
"%(speed)s/s") % \
{"current": current_item,
- "total": self.total_items,
- "speed": apt_pkg.size_to_str(self.current_cps)})
+ "total": self.totalItems,
+ "speed": apt_pkg.size_to_str(self.currentCPS)})
else:
text = (_("Downloading file %(current)li of %(total)li") % \
{"current": current_item,
- "total": self.total_items})
+ "total": self.totalItems})
self.emit("status-changed", text, self.percent)
while self._context.pending():
self._context.iteration()
@@ -328,19 +316,6 @@ class GtkAptProgress(gtk.VBox):
self._on_status_timeout)
self._progress_install.connect("status-conffile",
self._on_status_timeout)
- self._progress_dpkg_install = GDpkgInstallProgress(self._terminal)
- self._progress_dpkg_install.connect("status-changed",
- self._on_status_changed)
- self._progress_dpkg_install.connect("status-started",
- self._on_status_started)
- self._progress_dpkg_install.connect("status-finished",
- self._on_status_finished)
- self._progress_dpkg_install.connect("status-timeout",
- self._on_status_timeout)
- self._progress_dpkg_install.connect("status-error",
- self._on_status_timeout)
- self._progress_dpkg_install.connect("status-conffile",
- self._on_status_timeout)
def clear(self):
"""Reset all status information."""
@@ -361,7 +336,7 @@ class GtkAptProgress(gtk.VBox):
@property
def dpkg_install(self):
"""Return the install progress handler for dpkg."""
- return self._dpkg_progress_install
+ return self._progress_install
@property
def fetch(self):
@@ -383,7 +358,7 @@ class GtkAptProgress(gtk.VBox):
def _on_status_changed(self, progress, status, percent):
"""Called when the status changed."""
self._label.set_text(status)
- if percent is None:
+ if percent is None or percent == -1:
self._progressbar.pulse()
else:
self._progressbar.set_fraction(percent/100.0)
@@ -431,6 +406,7 @@ def _test():
"""Test function"""
import sys
+ import apt
from apt.debfile import DebPackage
win = gtk.Window()
diff --git a/apt/progress/old.py b/apt/progress/old.py
index 6b6e21de..c2d95b85 100644
--- a/apt/progress/old.py
+++ b/apt/progress/old.py
@@ -20,72 +20,51 @@
# USA
"""Deprecated progress reporting classes.
-This module provides classes for progress reporting. They can be used with
-e.g., for reporting progress on the cache opening process, the cache update
-progress, or the package install progress.
+This module provides classes for compatibility with python-apt 0.7. They are
+completely deprecated and should not be used anymore.
"""
-import errno
-import fcntl
+
import os
-import re
-import select
import sys
import apt_pkg
from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by
+import warnings
from apt.progress import base, text
-
__all__ = []
class OpProgress(base.OpProgress):
- """Abstract class to implement reporting on cache opening.
-
- Subclass this class to implement simple Operation progress reporting.
- """
+ """Abstract class to implement reporting on cache opening."""
- if apt_pkg._COMPAT_0_7:
- subOp = AttributeDeprecatedBy('subop')
- Op = AttributeDeprecatedBy('op')
+ subOp = AttributeDeprecatedBy('subop')
+ Op = AttributeDeprecatedBy('op')
-class OpTextProgress(text.OpProgress):
+class OpTextProgress(OpProgress, text.OpProgress):
"""A simple text based cache open reporting class."""
- if apt_pkg._COMPAT_0_7:
- subOp = AttributeDeprecatedBy('subop')
- Op = AttributeDeprecatedBy('op')
-
class FetchProgress(object):
- """Report the download/fetching progress.
-
- Subclass this class to implement fetch progress reporting
- """
+ """Report the download/fetching progress."""
# download status constants
- dl_done = 0
- dl_queued = 1
- dl_failed = 2
- dl_hit = 3
- dl_ignored = 4
- dl_status_str = {dl_done: "Done",
- dl_queued: "Queued",
- dl_failed: "Failed",
- dl_hit: "Hit",
- dl_ignored: "Ignored"}
+ (dlDone, dlQueued, dlFailed, dlHit, dlIgnored) = range(5)
+ dlStatusStr = {dlDone: "Done", dlQueued: "Queued", dlFailed: "Failed",
+ dlHit: "Hit", dlIgnored: "Ignored"}
def __init__(self):
self.eta = 0.0
self.percent = 0.0
# Make checking easier
- self.current_bytes = 0
- self.current_items = 0
- self.total_bytes = 0
- self.total_items = 0
- self.current_cps = 0
+ self.currentBytes = 0
+ self.currentItems = 0
+ self.totalBytes = 0
+ self.totalItems = 0
+ self.currentCPS = 0
+ warnings.warn("FetchProgress() is deprecated.", DeprecationWarning)
def start(self):
"""Called when the fetching starts."""
@@ -93,7 +72,7 @@ class FetchProgress(object):
def stop(self):
"""Called when all files have been fetched."""
- def update_status(self, uri, descr, short_descr, status):
+ def updateStatus(self, uri, descr, short_descr, status):
"""Called when the status of an item changes.
This happens eg. when the downloads fails or is completed.
@@ -112,11 +91,11 @@ class FetchProgress(object):
Return True to continue or False to cancel.
"""
- self.percent = (((self.current_bytes + self.current_items) * 100.0) /
- float(self.total_bytes + self.total_items))
- if self.current_cps > 0:
- self.eta = ((self.total_bytes - self.current_bytes) /
- float(self.current_cps))
+ self.percent = (((self.currentBytes + self.currentItems) * 100.0) /
+ float(self.totalBytes + self.totalItems))
+ if self.currentCPS > 0:
+ self.eta = ((self.totalBytes - self.currentBytes) /
+ float(self.currentCPS))
return True
def pulse_items(self, items):
@@ -125,31 +104,16 @@ class FetchProgress(object):
Return True to continue or False to cancel.
"""
- self.percent = (((self.current_bytes + self.current_items) * 100.0) /
- float(self.total_bytes + self.total_items))
- if self.current_cps > 0:
- self.eta = ((self.total_bytes - self.current_bytes) /
- float(self.current_cps))
+ self.percent = (((self.currentBytes + self.currentItems) * 100.0) /
+ float(self.totalBytes + self.totalItems))
+ if self.currentCPS > 0:
+ self.eta = ((self.totalBytes - self.currentBytes) /
+ float(self.currentCPS))
return True
- def media_change(self, medium, drive):
+ def mediaChange(self, medium, drive):
"""react to media change events."""
- if apt_pkg._COMPAT_0_7:
- dlDone = AttributeDeprecatedBy('dl_done')
- dlQueued = AttributeDeprecatedBy('dl_queued')
- dlFailed = AttributeDeprecatedBy('dl_failed')
- dlHit = AttributeDeprecatedBy('dl_hit')
- dlIgnored = AttributeDeprecatedBy('dl_ignored')
- dlStatusStr = AttributeDeprecatedBy('dl_status_str')
- currentBytes = AttributeDeprecatedBy('current_bytes')
- currentItems = AttributeDeprecatedBy('current_items')
- totalBytes = AttributeDeprecatedBy('total_bytes')
- totalItems = AttributeDeprecatedBy('total_items')
- currentCPS = AttributeDeprecatedBy('current_cps')
- updateStatus = function_deprecated_by(update_status)
- mediaChange = function_deprecated_by(media_change)
-
class TextFetchProgress(FetchProgress):
""" Ready to use progress object for terminal windows """
@@ -158,13 +122,13 @@ class TextFetchProgress(FetchProgress):
FetchProgress.__init__(self)
self.items = {}
- def update_status(self, uri, descr, short_descr, status):
+ def updateStatus(self, uri, descr, short_descr, status):
"""Called when the status of an item changes.
This happens eg. when the downloads fails or is completed.
"""
- if status != self.dl_queued:
- print "\r%s %s" % (self.dl_status_str[status], descr)
+ if status != self.dlQueued:
+ print "\r%s %s" % (self.dlStatusStr[status], descr)
self.items[uri] = status
def pulse(self):
@@ -173,9 +137,9 @@ class TextFetchProgress(FetchProgress):
Return True to continue or False to cancel.
"""
FetchProgress.pulse(self)
- if self.current_cps > 0:
+ if self.currentCPS > 0:
s = "[%2.f%%] %sB/s %s" % (self.percent,
- apt_pkg.size_to_str(int(self.current_cps)),
+ apt_pkg.size_to_str(int(self.currentCPS)),
apt_pkg.time_to_str(int(self.eta)))
else:
s = "%2.f%% [Working]" % (self.percent)
@@ -187,16 +151,23 @@ class TextFetchProgress(FetchProgress):
"""Called when all files have been fetched."""
print "\rDone downloading "
- def media_change(self, medium, drive):
+ def mediaChange(self, medium, drive):
"""react to media change events."""
print ("Media change: please insert the disc labeled "
"'%s' in the drive '%s' and press enter") % (medium, drive)
return raw_input() not in ('c', 'C')
- if apt_pkg._COMPAT_0_7:
- updateStatus = function_deprecated_by(update_status)
- mediaChange = function_deprecated_by(media_change)
+
+class CdromProgress(base.CdromProgress):
+ """Report the cdrom add progress.
+
+ This class has been replaced by apt_pkg.CdromProgress.
+ """
+ _basetype = base.CdromProgress
+ askCdromName = function_deprecated_by(_basetype.ask_cdrom_name)
+ changeCdrom = function_deprecated_by(_basetype.change_cdrom)
+ del _basetype
class DumbInstallProgress(base.InstallProgress):
@@ -208,127 +179,19 @@ class DumbInstallProgress(base.InstallProgress):
startUpdate = function_deprecated_by(base.InstallProgress.start_update)
finishUpdate = function_deprecated_by(base.InstallProgress.finish_update)
updateInterface = function_deprecated_by(
- base.InstallProgress.update_interface)
+ base.InstallProgress.update_interface)
-class InstallProgress(DumbInstallProgress):
+class InstallProgress(DumbInstallProgress, base.InstallProgress):
"""An InstallProgress that is pretty useful.
It supports the attributes 'percent' 'status' and callbacks for the dpkg
errors and conffiles and status changes.
"""
- def __init__(self):
- DumbInstallProgress.__init__(self)
- self.select_timeout = 0.1
- (read, write) = os.pipe()
- self.writefd = write
- self.statusfd = os.fdopen(read, "r")
- fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
- self.read = ""
- self.percent = 0.0
- self.status = ""
-
- def error(self, pkg, errormsg):
- """Called when a error is detected during the install."""
-
- def conffile(self, current, new):
- """Called when a conffile question from dpkg is detected."""
-
- def status_change(self, pkg, percent, status):
- """Called when the status changed."""
-
- def update_interface(self):
- """Called periodically to update the interface."""
- if self.statusfd is None:
- return
- try:
- while not self.read.endswith("\n"):
- self.read += os.read(self.statusfd.fileno(), 1)
- except OSError, (errno_, errstr):
- # resource temporarly unavailable is ignored
- if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK:
- print errstr
- if not self.read.endswith("\n"):
- return
-
- s = self.read
- #print s
- try:
- (status, pkg, percent, status_str) = s.split(":", 3)
- except ValueError:
- # 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)
- elif status == "pmconffile":
- # we get a string like this:
- # 'current-conffile' 'new-conffile' useredited distedited
- match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str)
- if match:
- self.conffile(match.group(1), match.group(2))
- elif status == "pmstatus":
- if float(percent) != self.percent or status_str != self.status:
- self.status_change(pkg, float(percent),
- status_str.strip())
- self.percent = float(percent)
- self.status = status_str.strip()
- self.read = ""
-
- def fork(self):
- """Fork."""
- return os.fork()
-
- def wait_child(self):
- """Wait for child progress to exit."""
- while True:
- try:
- select.select([self.statusfd], [], [], self.select_timeout)
- except select.error, (errno_, errstr):
- if errno_ != errno.EINTR:
- raise
-
- self.update_interface()
- try:
- (pid, res) = os.waitpid(self.child_pid, os.WNOHANG)
- if pid == self.child_pid:
- break
- except OSError, (errno_, errstr):
- if errno_ != errno.EINTR:
- raise
- if errno_ == errno.ECHILD:
- break
- return res
-
- def run(self, pm):
- """Start installing."""
- pid = self.fork()
- if pid == 0:
- # child
- res = pm.do_install(self.writefd)
- os._exit(res)
- self.child_pid = pid
- res = self.wait_child()
- return os.WEXITSTATUS(res)
-
- if apt_pkg._COMPAT_0_7:
- selectTimeout = AttributeDeprecatedBy('select_timeout')
- statusChange = function_deprecated_by(status_change)
- waitChild = function_deprecated_by(wait_child)
- updateInterface = function_deprecated_by(update_interface)
-
-
-class CdromProgress(base.CdromProgress):
- """Report the cdrom add progress.
-
- This class has been replaced by apt_pkg.CdromProgress.
- """
- _basetype = base.CdromProgress
- askCdromName = function_deprecated_by(_basetype.ask_cdrom_name)
- changeCdrom = function_deprecated_by(_basetype.change_cdrom)
- del _basetype
+ selectTimeout = AttributeDeprecatedBy('select_timeout')
+ statusChange = function_deprecated_by(base.InstallProgress.status_change)
+ waitChild = function_deprecated_by(base.InstallProgress.wait_child)
class DpkgInstallProgress(InstallProgress):
@@ -336,54 +199,7 @@ class DpkgInstallProgress(InstallProgress):
def run(self, debfile):
"""Start installing the given Debian package."""
- if apt_pkg._COMPAT_0_7: # Deprecated stuff
- 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, debfile))
- os._exit(os.WEXITSTATUS(res))
- self.child_pid = pid
- res = self.wait_child()
- return res
-
- def update_interface(self):
- """Process status messages from dpkg."""
- if self.statusfd is None:
- return
- 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 not self.read.endswith("\n"):
- continue
-
- statusl = self.read.split(":")
- if len(statusl) < 3:
- print "got garbage from dpkg: '%s'" % self.read
- self.read = ""
- break
- pkg_name = statusl[1].strip()
- status = statusl[2].strip()
- #print status
- if status == "error":
- self.error(pkg_name, status)
- elif status == "conffile-prompt":
- # we get a string like this:
- # 'current-conffile' 'new-conffile' useredited distedited
- match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", statusl[3])
- if match:
- self.conffile(match.group(1), match.group(2))
- else:
- self.status = status
- self.read = ""
-
- if apt_pkg._COMPAT_0_7:
- updateInterface = function_deprecated_by(update_interface)
+ # Deprecated stuff
+ self.debfile = debfile
+ self.debname = os.path.basename(debfile).split("_")[0]
+ return base.InstallProgress(self, debfile)
diff --git a/apt/progress/text.py b/apt/progress/text.py
index eb474d6d..3a6d3e65 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -257,3 +257,5 @@ class CdromProgress(base.CdromProgress, TextProgress):
return (raw_input() == '')
except KeyboardInterrupt:
return False
+
+InstallProgress = base.InstallProgress