diff options
Diffstat (limited to 'apt/progress')
| -rw-r--r-- | apt/progress/__init__.py | 14 | ||||
| -rw-r--r-- | apt/progress/base.py | 7 | ||||
| -rw-r--r-- | apt/progress/gtk2.py | 519 | ||||
| -rw-r--r-- | apt/progress/old.py | 259 | ||||
| -rw-r--r-- | apt/progress/text.py | 26 |
5 files changed, 26 insertions, 799 deletions
diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 10c11021..1ae94d06 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -19,17 +19,11 @@ """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. +'base' provides classes with no output, and the module 'text' provides classes +for terminals, etc. """ -import apt_pkg - -__all__ = [] +from __future__ import print_function -if apt_pkg._COMPAT_0_7: - from apt.progress.old import (CdromProgress, DpkgInstallProgress, - DumbInstallProgress, FetchProgress, - InstallProgress, OpProgress, - OpTextProgress, TextFetchProgress) +__all__ = [] diff --git a/apt/progress/base.py b/apt/progress/base.py index 2c80ae29..95eca9ec 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -22,6 +22,8 @@ Custom progress classes should inherit from these classes. They can also be used as dummy progress classes which simply do nothing. """ +from __future__ import print_function + import errno import fcntl import os @@ -217,7 +219,7 @@ class InstallProgress(object): except IOError as err: # resource temporarly unavailable is ignored if err.errno != errno.EAGAIN and err.errno != errno.EWOULDBLOCK: - print err.strerror + print(err.strerror) return pkgname = status = status_str = percent = base = "" @@ -269,7 +271,8 @@ class InstallProgress(object): try: select.select([self.status_stream], [], [], self.select_timeout) - except select.error as (errno_, _errstr): + except select.error as error: + (errno_, _errstr) = error.args if errno_ != errno.EINTR: raise diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py deleted file mode 100644 index c2635ca0..00000000 --- a/apt/progress/gtk2.py +++ /dev/null @@ -1,519 +0,0 @@ -#!/usr/bin/env python -# -# Copyright (c) 2004-2009 Canonical -# -# Authors: Michael Vogt <michael.vogt@ubuntu.com> -# Sebastian Heinlein <glatzor@ubuntu.com> -# Julian Andres Klode <jak@debian.org> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA -"""GObject-powered progress classes and a GTK+ status widget.""" - -import pygtk -pygtk.require('2.0') -import gtk -try: - import glib -except ImportError: - import gobject as glib -import gobject -import pango -import time -import vte - -import apt_pkg -from apt_pkg import gettext as _ -from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy -from apt.progress import base - -if apt_pkg._COMPAT_0_7: - from apt.progress import old - - -__all__ = ['GAcquireProgress', 'GInstallProgress', 'GOpProgress', - 'GtkAptProgress'] - - -def mksig(params=(), run=gobject.SIGNAL_RUN_FIRST, rettype=gobject.TYPE_NONE): - """Simplified Create a gobject signal. - - This allows us to write signals easier, because we just need to define the - type of the parameters (in most cases). - - ``params`` is a tuple which defines the types of the arguments. - """ - return (run, rettype, params) - - -class GOpProgress(gobject.GObject, base.OpProgress): - """Operation progress with GObject signals. - - Signals: - - * status-changed(str: operation, int: percent) - * status-started() - Not Implemented yet - * status-finished() - - """ - - __gsignals__ = {"status-changed": mksig((str, int)), - "status-started": mksig(), - "status-finished": mksig()} - - def __init__(self): - base.OpProgress.__init__(self) - gobject.GObject.__init__(self) - self._context = glib.main_context_default() - - def update(self, percent=None): - """Called to update the percentage done""" - base.OpProgress.update(self, percent) - self.emit("status-changed", self.op, self.percent) - while self._context.pending(): - self._context.iteration() - - def done(self): - """Called when all operation have finished.""" - base.OpProgress.done(self) - self.emit("status-finished") - - if apt_pkg._COMPAT_0_7: - subOp = AttributeDeprecatedBy('subop') - Op = AttributeDeprecatedBy('op') - - -class GInstallProgress(gobject.GObject, base.InstallProgress): - """Installation progress with GObject signals. - - Signals: - - * status-changed(str: status, int: percent) - * status-started() - * status-finished() - * status-timeout() - * status-error() - * status-conffile() - - """ - # Seconds until a maintainer script will be regarded as hanging - INSTALL_TIMEOUT = 5 * 60 - - __gsignals__ = {"status-changed": mksig((str, int)), - "status-started": mksig(), - "status-timeout": mksig(), - "status-error": mksig(), - "status-conffile": mksig(), - "status-finished": mksig()} - - def __init__(self, term): - base.InstallProgress.__init__(self) - gobject.GObject.__init__(self) - self.finished = False - self.apt_status = -1 - self.time_last_update = time.time() - self.term = term - self.term.connect("child-exited", self.child_exited) - self.env = ["VTE_PTY_KEEP_FD=%s" % self.writefd, - "DEBIAN_FRONTEND=gnome", - "APT_LISTCHANGES_FRONTEND=gtk"] - self._context = glib.main_context_default() - - def child_exited(self, term): - """Called when a child process exits""" - self.apt_status = term.get_child_exit_status() - self.finished = True - - def error(self, pkg, errormsg): - """Called when an error happens. - - Emits: status-error() - """ - self.emit("status-error") - - def conffile(self, current, new): - """Called during conffile. - - Emits: status-conffile() - """ - self.emit("status-conffile") - - def start_update(self): - """Called when the update starts. - - Emits: status-started() - """ - 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. - - Emits: status-finished() - """ - 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. - - Emits: status-changed(status, percent) - """ - self.time_last_update = time.time() - self.emit("status-changed", status, percent) - - def update_interface(self): - """Called periodically to update the interface. - - Emits: status-timeout() [When a timeout happens] - """ - base.InstallProgress.update_interface(self) - while self._context.pending(): - self._context.iteration() - if self.time_last_update + self.INSTALL_TIMEOUT < time.time(): - self.emit("status-timeout") - - def fork(self): - """Fork the process.""" - return self.term.forkpty(envv=self.env) - - def wait_child(self): - """Wait for the child process to exit.""" - while not self.finished: - self.update_interface() - time.sleep(0.02) - return self.apt_status - - if apt_pkg._COMPAT_0_7: - updateInterface = function_deprecated_by(update_interface) - startUpdate = function_deprecated_by(start_update) - finishUpdate = function_deprecated_by(finish_update) - statusChange = function_deprecated_by(status_change) - waitChild = function_deprecated_by(wait_child) - childExited = function_deprecated_by(child_exited) - - -GDpkgInstallProgress = GInstallProgress - - -class GAcquireProgress(gobject.GObject, base.AcquireProgress): - """A Fetch Progress with GObject signals. - - Signals: - - * status-changed(str: description, int: percent) - * status-started() - * status-finished() - - DEPRECATED. - """ - - __gsignals__ = {"status-changed": mksig((str, int)), - "status-started": mksig(), - "status-finished": mksig()} - - def __init__(self): - base.AcquireProgress.__init__(self) - gobject.GObject.__init__(self) - self._continue = True - self._context = glib.main_context_default() - - def start(self): - base.AcquireProgress.start(self) - self.emit("status-started") - - def stop(self): - base.AcquireProgress.stop(self) - self.emit("status-finished") - - def cancel(self): - self._continue = False - - def pulse(self, owner): - base.AcquireProgress.pulse(self, owner) - current_item = self.current_items + 1 - if current_item > self.total_items: - current_item = self.total_items - 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)}) - else: - text = (_("Downloading file %(current)li of %(total)li") % \ - {"current": current_item, - "total": self.total_items}) - - percent = (((self.current_bytes + self.current_items) * 100.0) / - float(self.total_bytes + self.total_items)) - self.emit("status-changed", text, percent) - while self._context.pending(): - self._context.iteration() - return self._continue - -if apt_pkg._COMPAT_0_7: - - class GFetchProgress(gobject.GObject, old.FetchProgress): - """A Fetch Progress with GObject signals. - - Signals: - - * status-changed(str: description, int: percent) - * status-started() - * status-finished() - - DEPRECATED. - """ - - __gsignals__ = {"status-changed": mksig((str, int)), - "status-started": mksig(), - "status-finished": mksig()} - - def __init__(self): - old.FetchProgress.__init__(self) - gobject.GObject.__init__(self) - self._continue = True - self._context = glib.main_context_default() - - def start(self): - self.emit("status-started") - - def stop(self): - self.emit("status-finished") - - def cancel(self): - self._continue = False - - def pulse(self): - old.FetchProgress.pulse(self) - 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.totalItems, - "speed": apt_pkg.size_to_str(self.currentCPS)}) - else: - text = (_("Downloading file %(current)li of %(total)li") % \ - {"current": current_item, - "total": self.totalItems}) - self.emit("status-changed", text, self.percent) - while self._context.pending(): - self._context.iteration() - return self._continue - - -class GtkAptProgress(gtk.VBox): - """Graphical progress for installation/fetch/operations. - - This widget provides a progress bar, a terminal and a status bar for - showing the progress of package manipulation tasks. - """ - - def __init__(self): - gtk.VBox.__init__(self) - self.set_spacing(6) - # Setup some child widgets - self._expander = gtk.Expander(_("Details")) - self._terminal = vte.Terminal() - #self._terminal.set_font_from_string("monospace 10") - self._expander.add(self._terminal) - self._progressbar = gtk.ProgressBar() - # Setup the always italic status label - self._label = gtk.Label() - attr_list = pango.AttrList() - attr_list.insert(pango.AttrStyle(pango.STYLE_ITALIC, 0, -1)) - self._label.set_attributes(attr_list) - self._label.set_ellipsize(pango.ELLIPSIZE_END) - self._label.set_alignment(0, 0) - # add child widgets - self.pack_start(self._progressbar, False) - self.pack_start(self._label, False) - self.pack_start(self._expander, False) - # Setup the internal progress handlers - self._progress_open = GOpProgress() - self._progress_open.connect("status-changed", self._on_status_changed) - self._progress_open.connect("status-started", self._on_status_started) - self._progress_open.connect("status-finished", - self._on_status_finished) - self._progress_acquire = GAcquireProgress() - self._progress_acquire.connect("status-changed", - self._on_status_changed) - self._progress_acquire.connect("status-started", - self._on_status_started) - self._progress_acquire.connect("status-finished", - self._on_status_finished) - - self._progress_fetch = None - self._progress_install = GInstallProgress(self._terminal) - self._progress_install.connect("status-changed", - self._on_status_changed) - self._progress_install.connect("status-started", - self._on_status_started) - self._progress_install.connect("status-finished", - self._on_status_finished) - self._progress_install.connect("status-timeout", - self._on_status_timeout) - self._progress_install.connect("status-error", - self._on_status_timeout) - self._progress_install.connect("status-conffile", - self._on_status_timeout) - - def clear(self): - """Reset all status information.""" - self._label.set_label("") - self._progressbar.set_fraction(0) - self._expander.set_expanded(False) - - @property - def open(self): - """Return the cache opening progress handler.""" - return self._progress_open - - @property - def install(self): - """Return the install progress handler.""" - return self._progress_install - - @property - def dpkg_install(self): - """Return the install progress handler for dpkg.""" - return self._progress_install - - if apt_pkg._COMPAT_0_7: - - @property - def fetch(self): - """Return the fetch progress handler.""" - if self._progress_fetch is None: - self._progress_fetch = GFetchProgress() - self._progress_fetch.connect("status-changed", - self._on_status_changed) - self._progress_fetch.connect("status-started", - self._on_status_started) - self._progress_fetch.connect("status-finished", - self._on_status_finished) - return self._progress_fetch - - @property - def acquire(self): - """Return the acquire progress handler.""" - return self._progress_acquire - - def _on_status_started(self, progress): - """Called when something starts.""" - self._on_status_changed(progress, _("Starting..."), 0) - while gtk.events_pending(): - gtk.main_iteration() - - def _on_status_finished(self, progress): - """Called when something finished.""" - self._on_status_changed(progress, _("Complete"), 100) - while gtk.events_pending(): - gtk.main_iteration() - - def _on_status_changed(self, progress, status, percent): - """Called when the status changed.""" - self._label.set_text(status) - if percent is None or percent == -1: - self._progressbar.pulse() - else: - self._progressbar.set_fraction(percent/100.0) - while gtk.events_pending(): - gtk.main_iteration() - - def _on_status_timeout(self, progress): - """Called when timeout happens.""" - self._expander.set_expanded(True) - while gtk.events_pending(): - gtk.main_iteration() - - def cancel_download(self): - """Cancel a currently running download.""" - self._progress_fetch.cancel() - - def show_terminal(self, expanded=False): - """Show the expander for the terminal. - - Show an expander with a terminal widget which provides a way - to interact with dpkg - """ - self._expander.show() - self._terminal.show() - self._expander.set_expanded(expanded) - while gtk.events_pending(): - gtk.main_iteration() - - def hide_terminal(self): - """Hide the expander with the terminal widget.""" - self._expander.hide() - while gtk.events_pending(): - gtk.main_iteration() - - def show(self): - """Show the Box""" - gtk.HBox.show(self) - self._label.show() - self._progressbar.show() - while gtk.events_pending(): - gtk.main_iteration() - - -def _test(): - """Test function""" - import sys - - import apt - from apt.debfile import DebPackage - - win = gtk.Window() - apt_progress = GtkAptProgress() - win.set_title("GtkAptProgress Demo") - win.add(apt_progress) - apt_progress.show() - win.show() - cache = apt.cache.Cache(apt_progress.open) - pkg = cache["xterm"] - if pkg.is_installed: - pkg.mark_delete() - else: - pkg.mark_install() - apt_progress.show_terminal(True) - try: - cache.commit(apt_progress.acquire, apt_progress.install) - except Exception as exc: - print >> sys.stderr, "Exception happened:", exc - if len(sys.argv) > 1: - deb = DebPackage(sys.argv[1], cache) - deb.install(apt_progress.dpkg_install) - win.connect("destroy", gtk.main_quit) - gtk.main() - - -if __name__ == "__main__": - _test() - -# vim: ts=4 et sts=4 diff --git a/apt/progress/old.py b/apt/progress/old.py deleted file mode 100644 index 364cd2ce..00000000 --- a/apt/progress/old.py +++ /dev/null @@ -1,259 +0,0 @@ -# progress.py - progress reporting classes -# -# Copyright (c) 2005-2009 Canonical -# -# Author: Michael Vogt <michael.vogt@ubuntu.com> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# 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. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA -# pylint: disable-msg = C0103 -"""Deprecated progress reporting classes. - -This module provides classes for compatibility with python-apt 0.7. They are -completely deprecated and should not be used anymore. -""" - - -import os -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.""" - - def __init__(self): - base.OpProgress.__init__(self) - warnings.warn("apt.progress.OpProgress is deprecated.", - DeprecationWarning, stacklevel=2) - - subOp = AttributeDeprecatedBy('subop') - Op = AttributeDeprecatedBy('op') - - -class OpTextProgress(OpProgress, text.OpProgress): - """A simple text based cache open reporting class.""" - - def __init__(self): - text.OpProgress.__init__(self) - warnings.warn("apt.progress.OpTextProgress is deprecated.", - DeprecationWarning, stacklevel=2) - - -class FetchProgress(object): - """Report the download/fetching progress.""" - - # download status constants - (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.currentBytes = 0 - self.currentItems = 0 - self.totalBytes = 0 - self.totalItems = 0 - self.currentCPS = 0 - warnings.warn("apt.progress.FetchProgress is deprecated.", - DeprecationWarning, stacklevel=2) - - def start(self): - """Called when the fetching starts.""" - - def stop(self): - """Called when all files have been fetched.""" - - 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. - """ - - def update_status_full(self, uri, descr, short_descr, status, file_size, - partial_size): - """Called when the status of an item changes. - - This happens eg. when the downloads fails or is completed. This - version include information on current filesize and partial size - """ - - def pulse(self): - """Called periodically to update the user interface. - - Return True to continue or False to cancel. - """ - 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): - """Called periodically to update the user interface. - This function includes details about the items being fetched - Return True to continue or False to cancel. - - """ - 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 mediaChange(self, medium, drive): - """react to media change events.""" - - -class TextFetchProgress(FetchProgress): - """ Ready to use progress object for terminal windows """ - - def __init__(self): - FetchProgress.__init__(self) - self.items = {} - - 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.dlQueued: - print "\r%s %s" % (self.dlStatusStr[status], descr) - self.items[uri] = status - - def pulse(self): - """Called periodically to update the user interface. - - Return True to continue or False to cancel. - """ - FetchProgress.pulse(self) - - if self.currentCPS > 0: - s = "[%2.f%%] %sB/s %s" % (self.percent, - apt_pkg.size_to_str(self.currentCPS), - apt_pkg.time_to_str(long(self.eta))) - else: - s = "%2.f%% [Working]" % (self.percent) - print "\r%s" % (s), - sys.stdout.flush() - return True - - def stop(self): - """Called when all files have been fetched.""" - print "\rDone downloading " - - 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') - - -class CdromProgress(object): - """Report the cdrom add progress.""" - - def __init__(self): - warnings.warn("apt.progress.CdromProgress is deprecated.", - DeprecationWarning, stacklevel=2) - - def askCdromName(self): - """Ask for a cdrom name""" - - def changeCdrom(self): - """Change cdrom""" - - def update(self, text, current): - """Update.""" - - -class DumbInstallProgress(base.InstallProgress): - """Report the install progress.""" - - def __init__(self): - base.InstallProgress.__init__(self) - warnings.warn("apt.progress.*InstallProgress are deprecated.", - DeprecationWarning, stacklevel=2) - - def updateInterface(self): - # *_stream were not available in the old progress reporting classes, - # create the attributes if they do not exist yet; as they are used - # in base.InstallProgress.update_interface(). - if hasattr(self, "writefd") and not hasattr(self, "write_stream"): - self.write_stream = os.fdopen(self.writefd, "w") - if hasattr(self, "statusfd") and not hasattr(self, "status_stream"): - self.status_stream = os.fdopen(self.statusfd, "r") - return base.InstallProgress.update_interface(self) - - def update_interface(self): - return self.updateInterface() - - def startUpdate(self): - return base.InstallProgress.start_update(self) - - def start_update(self): - return self.startUpdate() - - def finishUpdate(self): - return base.InstallProgress.finish_update(self) - - def finish_update(self): - return self.finishUpdate() - - -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. - """ - - selectTimeout = AttributeDeprecatedBy('select_timeout') - - def statusChange(self, pkg, percent, status): - return base.InstallProgress.status_change(self, pkg, percent, status) - - def status_change(self, pkg, percent, status): - return self.statusChange(pkg, percent, status) - - def waitChild(self): - return base.InstallProgress.wait_child(self) - - def wait_child(self): - return self.waitChild() - - -class DpkgInstallProgress(InstallProgress): - """Progress handler for a local Debian package installation.""" - - debfile = "" - debname = "" - - def run(self, debfile): - """Start installing the given Debian package.""" - # Deprecated stuff - self.debfile = debfile - self.debname = os.path.basename(debfile).split("_")[0] - return base.InstallProgress.run(self, debfile) diff --git a/apt/progress/text.py b/apt/progress/text.py index c5eec092..d1f87539 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -15,6 +15,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA """Progress reporting for text interfaces.""" +from __future__ import print_function + import os import sys @@ -23,6 +25,11 @@ from apt.progress import base __all__ = ['AcquireProgress', 'CdromProgress', 'OpProgress'] +if sys.version_info.major < 3: + input = raw_input +else: + long = int + def _(msg): """Translate the message, also try apt if translation is missing.""" @@ -47,7 +54,7 @@ class TextProgress(object): # Fill remaining stuff with whitespace if self._width > len(msg): self._file.write((self._width - len(msg)) * ' ') - elif maximize: # Needed for OpProgress. + elif maximize: # Needed for OpProgress. self._width = max(self._width, len(msg)) if newline: self._file.write("\n") @@ -91,7 +98,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress): base.AcquireProgress.__init__(self) self._signal = None self._width = 80 - self._id = 1 + self._id = long(1) def start(self): """Start an Acquire progress. @@ -104,7 +111,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress): self._signal = signal.signal(signal.SIGWINCH, self._winch) # Get the window size. self._winch() - self._id = 1L + self._id = long(1) def _winch(self, *dummy): """Signal handler for window resize signals.""" @@ -114,7 +121,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress): import struct buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ') dummy, col, dummy, dummy = struct.unpack('hhhh', buf) - self._width = col - 1 # 1 for the cursor + self._width = col - 1 # 1 for the cursor def ims_hit(self, item): """Called when an item is update (e.g. not modified on the server).""" @@ -188,8 +195,9 @@ class AcquireProgress(base.AcquireProgress, TextProgress): # Add the total size and percent if worker.total_size and not worker.current_item.owner.complete: - val += "/%sB %i%%" % (apt_pkg.size_to_str(worker.total_size), - worker.current_size*100.0/worker.total_size) + val += "/%sB %i%%" % ( + apt_pkg.size_to_str(worker.total_size), + worker.current_size * 100.0 / worker.total_size) val += ']' @@ -214,7 +222,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress): self._write(_("Media change: please insert the disc labeled\n" " '%s'\n" "in the drive '%s' and press enter\n") % (medium, drive)) - return raw_input() not in ('c', 'C') + return input() not in ('c', 'C') def stop(self): """Invoked when the Acquire process stops running.""" @@ -239,7 +247,7 @@ class CdromProgress(base.CdromProgress, TextProgress): self._write(_("Please provide a name for this Disc, such as " "'Debian 2.1r1 Disk 1'"), False) try: - return raw_input(":") + return input(":") except KeyboardInterrupt: return @@ -255,6 +263,6 @@ class CdromProgress(base.CdromProgress, TextProgress): self._write(_("Please insert a Disc in the drive and press enter"), False) try: - return (raw_input() == '') + return (input() == '') except KeyboardInterrupt: return False |
