summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-07-17 17:24:58 +0200
committerJulian Andres Klode <jak@debian.org>2009-07-17 17:24:58 +0200
commitdb6032394c794c6bbe59675bb38802d208d993cb (patch)
tree51f90ddd7f452e663e5f507d2491035cd73da497 /apt
parent16c00d2037cde6da07b4988dbd35ebce0af56791 (diff)
downloadpython-apt-db6032394c794c6bbe59675bb38802d208d993cb.tar.gz
apt/progress/text.py: Improve final summary.
Diffstat (limited to 'apt')
-rw-r--r--apt/progress/text.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/apt/progress/text.py b/apt/progress/text.py
index b50502e6..ba8e158d 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -16,7 +16,7 @@
# USA
"""Progress reporting for text interfaces."""
import sys
-from gettext import gettext, dgettext
+from gettext import dgettext
import apt_pkg
@@ -90,15 +90,22 @@ class AcquireProgress(apt_pkg.AcquireProgress, TextProgress):
def __init__(self, outfile=None):
TextProgress.__init__(self, outfile)
apt_pkg.AcquireProgress.__init__(self)
+ self._signal = None
+ self._width = 80
+ self._id = 1
+
+ def start(self):
+ """Start an Acquire progress.
+
+ In this case, the function sets up a signal handler for SIGWINCH, i.e.
+ window resize signals. And it also sets id to 1.
+ """
import signal
self._signal = signal.signal(signal.SIGWINCH, self._winch)
+ # Get the window size.
self._winch()
self._id = 1L
- def __del__(self):
- import signal
- signal.signal(signal.SIGWINCH, self._signal)
-
def _winch(self, *dummy):
"""Signal handler for window resize signals."""
import fcntl
@@ -136,10 +143,6 @@ class AcquireProgress(apt_pkg.AcquireProgress, TextProgress):
self._write(line)
- @staticmethod
- def _fmt_worker(worker):
- """Format a worker."""
-
def pulse(self, owner):
"""Periodically invoked while the Acquire process is underway.
@@ -188,6 +191,7 @@ class AcquireProgress(apt_pkg.AcquireProgress, TextProgress):
val += ']'
if len(tval) + len(val) + len(end) >= self._width:
+ # Display as many items as screen width
break
else:
tval += val
@@ -210,8 +214,12 @@ class AcquireProgress(apt_pkg.AcquireProgress, TextProgress):
def stop(self):
"""Invoked when the Acquire process stops running."""
- if self.fetched_bytes:
- self._write(_("Fetched %sB in %s (%sB/s)\n") % (
- apt_pkg.size_to_str(self.fetched_bytes),
- apt_pkg.time_to_str(self.elapsed_time),
- apt_pkg.size_to_str(self.current_cps)), False)
+ # Trick for getting a translation from apt
+ self._write((_("Fetched %sB in %s (%sB/s)\n") % (
+ apt_pkg.size_to_str(self.fetched_bytes),
+ apt_pkg.time_to_str(self.elapsed_time),
+ apt_pkg.size_to_str(self.current_cps))).rstrip("\n"))
+
+ # Delete the signal again.
+ import signal
+ signal.signal(signal.SIGWINCH, self._signal)