summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py6
-rw-r--r--apt/cdrom.py3
-rw-r--r--apt/progress/old.py28
-rw-r--r--apt/progress/text.py36
4 files changed, 33 insertions, 40 deletions
diff --git a/apt/cache.py b/apt/cache.py
index f507863c..ae4254e0 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -122,11 +122,7 @@ class Cache(object):
size=len(self._cache.packages)
for pkg in self._cache.packages:
if progress is not None and last+100 < i:
- if isinstance(progress, apt_pkg.OpProgress):
- progress.percent = i/float(size)*100
- progress.update()
- else:
- progress.update(i/float(size)*100)
+ progress.update(i/float(size)*100)
last=i
# drop stuff with no versions (cruft)
if len(pkg.version_list) > 0:
diff --git a/apt/cdrom.py b/apt/cdrom.py
index 126c54dd..01caa12f 100644
--- a/apt/cdrom.py
+++ b/apt/cdrom.py
@@ -24,6 +24,7 @@ import glob
import apt_pkg
from apt.deprecation import AttributeDeprecatedBy
+from apt.progress.base import CdromProgress
class Cdrom(apt_pkg.Cdrom):
@@ -46,7 +47,7 @@ class Cdrom(apt_pkg.Cdrom):
def __init__(self, progress=None, mountpoint=None, nomount=True):
apt_pkg.Cdrom.__init__(self)
if progress is None:
- self._progress = apt_pkg.CdromProgress()
+ self._progress = CdromProgress()
else:
self._progress = progress
# see if we have a alternative mountpoint
diff --git a/apt/progress/old.py b/apt/progress/old.py
index 88957272..adaf94b2 100644
--- a/apt/progress/old.py
+++ b/apt/progress/old.py
@@ -34,29 +34,21 @@ import sys
import apt_pkg
from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by
+from apt.progress import base
__all__ = []
-class OpProgress(object):
+class OpProgress(base.OpProgress):
"""Abstract class to implement reporting on cache opening.
Subclass this class to implement simple Operation progress reporting.
"""
- def __init__(self):
- self.op = None
- self.subop = None
-
- def update(self, percent):
- """Called periodically to update the user interface."""
-
- def done(self):
- """Called once an operation has been completed."""
-
if apt_pkg._COMPAT_0_7:
subOp = AttributeDeprecatedBy('subop')
+ Op = AttributeDeprecatedBy('op')
class OpTextProgress(OpProgress):
@@ -65,13 +57,15 @@ class OpTextProgress(OpProgress):
def __init__(self):
OpProgress.__init__(self)
- def update(self, percent):
+ def update(self, percent=None):
"""Called periodically to update the user interface."""
- sys.stdout.write("\r%s: %.2i " % (self.subop, percent))
+ OpProgress.update(self, percent)
+ sys.stdout.write("\r%s: %.2i " % (self.subop, self.percent))
sys.stdout.flush()
def done(self):
"""Called once an operation has been completed."""
+ OpProgress.done(self)
sys.stdout.write("\r%s: Done\n" % self.op)
@@ -349,13 +343,15 @@ class InstallProgress(DumbInstallProgress):
updateInterface = function_deprecated_by(update_interface)
-class CdromProgress(apt_pkg.CdromProgress):
+class CdromProgress(base.CdromProgress):
"""Report the cdrom add progress.
This class has been replaced by apt_pkg.CdromProgress.
"""
- askCdromName = function_deprecated_by(apt_pkg.CdromProgress.ask_cdrom_name)
- changeCdrom = function_deprecated_by(apt_pkg.CdromProgress.change_cdrom)
+ _basetype = base.CdromProgress
+ askCdromName = function_deprecated_by(_basetype.ask_cdrom_name)
+ changeCdrom = function_deprecated_by(_basetype.change_cdrom)
+ del _basetype
class DpkgInstallProgress(InstallProgress):
diff --git a/apt/progress/text.py b/apt/progress/text.py
index 54a35704..eb474d6d 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -18,7 +18,7 @@
import sys
import apt_pkg
-import apt.progress.base
+from apt.progress import base
__all__ = ['AcquireProgress', 'CdromProgress', 'OpProgress']
@@ -55,7 +55,7 @@ class TextProgress(object):
self._file.flush()
-class OpProgress(apt.progress.base.OpProgress, TextProgress):
+class OpProgress(base.OpProgress, TextProgress):
"""Operation progress reporting.
This closely resembles OpTextProgress in libapt-pkg.
@@ -63,12 +63,12 @@ class OpProgress(apt.progress.base.OpProgress, TextProgress):
def __init__(self, outfile=None):
TextProgress.__init__(self, outfile)
- apt.progress.base.OpProgress.__init__(self)
+ base.OpProgress.__init__(self)
self.old_op = ""
def update(self, percent=None):
"""Called periodically to update the user interface."""
- apt.progress.base.OpProgress.update(self, percent)
+ base.OpProgress.update(self, percent)
if self.major_change and self.old_op:
self._write(self.old_op)
self._write("%s... %i%%\r" % (self.op, self.percent), False, True)
@@ -76,18 +76,18 @@ class OpProgress(apt.progress.base.OpProgress, TextProgress):
def done(self):
"""Called once an operation has been completed."""
- apt.progress.base.OpProgress.done(self)
+ base.OpProgress.done(self)
if self.old_op:
self._write(_("%c%s... Done") % ('\r', self.old_op), True, True)
self.old_op = ""
-class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
+class AcquireProgress(base.AcquireProgress, TextProgress):
"""AcquireProgress for the text interface."""
def __init__(self, outfile=None):
TextProgress.__init__(self, outfile)
- apt.progress.base.AcquireProgress.__init__(self)
+ base.AcquireProgress.__init__(self)
self._signal = None
self._width = 80
self._id = 1
@@ -98,7 +98,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
In this case, the function sets up a signal handler for SIGWINCH, i.e.
window resize signals. And it also sets id to 1.
"""
- apt.progress.base.AcquireProgress.start(self)
+ base.AcquireProgress.start(self)
import signal
self._signal = signal.signal(signal.SIGWINCH, self._winch)
# Get the window size.
@@ -116,7 +116,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
def ims_hit(self, item):
"""Called when an item is update (e.g. not modified on the server)."""
- apt.progress.base.AcquireProgress.ims_hit(self, item)
+ base.AcquireProgress.ims_hit(self, item)
line = _('Hit ') + item.description
if item.owner.filesize:
line += ' [%sB]' % apt_pkg.size_to_str(item.owner.filesize)
@@ -124,7 +124,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
def fail(self, item):
"""Called when an item is failed."""
- apt.progress.base.AcquireProgress.fail(self, item)
+ base.AcquireProgress.fail(self, item)
if item.owner.status == item.owner.stat_done:
self._write(_("Ign ") + item.description)
else:
@@ -133,7 +133,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
def fetch(self, item):
"""Called when some of the item's data is fetched."""
- apt.progress.base.AcquireProgress.fetch(self, item)
+ base.AcquireProgress.fetch(self, item)
# It's complete already (e.g. Hit)
if item.owner.complete:
return
@@ -149,7 +149,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
"""Periodically invoked while the Acquire process is underway.
Return False if the user asked to cancel the whole Acquire process."""
- apt.progress.base.AcquireProgress.pulse(self, owner)
+ base.AcquireProgress.pulse(self, owner)
percent = (((self.current_bytes + self.current_items) * 100.0) /
float(self.total_bytes + self.total_items))
@@ -209,7 +209,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
def media_change(self, medium, drive):
"""Prompt the user to change the inserted removable media."""
- apt.progress.base.AcquireProgress.media_change(self, medium, drive)
+ base.AcquireProgress.media_change(self, medium, drive)
self._write(_("Media change: please insert the disc labeled\n"
" '%s'\n"
"in the drive '%s' and press enter\n") % (medium, drive))
@@ -217,7 +217,7 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
def stop(self):
"""Invoked when the Acquire process stops running."""
- apt.progress.base.AcquireProgress.stop(self)
+ base.AcquireProgress.stop(self)
# Trick for getting a translation from apt
self._write((_("Fetched %sB in %s (%sB/s)\n") % (
apt_pkg.size_to_str(self.fetched_bytes),
@@ -229,12 +229,12 @@ class AcquireProgress(apt.progress.base.AcquireProgress, TextProgress):
signal.signal(signal.SIGWINCH, self._signal)
-class CdromProgress(apt.progress.base.CdromProgress, TextProgress):
+class CdromProgress(base.CdromProgress, TextProgress):
"""Text CD-ROM progress."""
def ask_cdrom_name(self):
"""Ask the user to provide a name for the disc."""
- apt.progress.base.CdromProgress.ask_cdrom_name(self)
+ base.CdromProgress.ask_cdrom_name(self)
self._write(_("Please provide a name for this Disc, such as "
"'Debian 2.1r1 Disk 1'"), False)
try:
@@ -244,13 +244,13 @@ class CdromProgress(apt.progress.base.CdromProgress, TextProgress):
def update(self, text, current):
"""Set the current progress."""
- apt.progress.base.CdromProgress.update(self, text, current)
+ base.CdromProgress.update(self, text, current)
if text:
self._write(text, False)
def change_cdrom(self):
"""Ask the user to change the CD-ROM."""
- apt.progress.base.CdromProgress.change_cdrom(self)
+ base.CdromProgress.change_cdrom(self)
self._write(_("Please insert a Disc in the drive and press enter"),
False)
try: