diff options
Diffstat (limited to 'apt/progress')
| -rw-r--r-- | apt/progress/base.py | 15 | ||||
| -rw-r--r-- | apt/progress/gtk2.py | 1 | ||||
| -rw-r--r-- | apt/progress/old.py | 92 | ||||
| -rw-r--r-- | apt/progress/text.py | 2 |
4 files changed, 80 insertions, 30 deletions
diff --git a/apt/progress/base.py b/apt/progress/base.py index 8075f790..6822b74a 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -16,6 +16,7 @@ # 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 = R0201 """Base classes for progress reporting. Custom progress classes should inherit from these classes. They can also be @@ -28,7 +29,6 @@ import re import select import apt_pkg -from apt.deprecation import function_deprecated_by __all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress'] @@ -137,7 +137,7 @@ class CdromProgress(object): class InstallProgress(object): """Class to report the progress of installing packages.""" - percent, select_timeout, status = 0.0, 0.1, "" + child_pid, percent, select_timeout, status = 0, 0.0, 0.1, "" def __init__(self): (self.statusfd, self.writefd) = os.pipe() @@ -159,9 +159,6 @@ class InstallProgress(object): def status_change(self, pkg, percent, status): """(Abstract) Called when the APT status changed.""" - # compat with 0.7 - if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"): - self.statusChange(pkg, percent, status) def dpkg_status_change(self, pkg, status): """(Abstract) Called when the dpkg status changed.""" @@ -197,7 +194,8 @@ class InstallProgress(object): os._exit(obj.do_install(self.write_stream.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", - str(self.write_stream.fileno()), "-i", obj)) + str(self.write_stream.fileno()), "-i", + obj)) except Exception: os._exit(apt_pkg.PackageManager.RESULT_FAILED) @@ -266,8 +264,9 @@ class InstallProgress(object): (pid, res) = (0, 0) while True: try: - select.select([self.status_stream], [], [], self.select_timeout) - except select.error, (errno_, errstr): + select.select([self.status_stream], [], [], + self.select_timeout) + except select.error, (errno_, _errstr): if errno_ != errno.EINTR: raise diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index 29e730a3..acb01eed 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -124,6 +124,7 @@ class GInstallProgress(gobject.GObject, base.InstallProgress): base.InstallProgress.__init__(self) gobject.GObject.__init__(self) self.finished = False + self.apt_status = -1 self.time_last_update = time.time() self.term = term reaper = vte.reaper_get() diff --git a/apt/progress/old.py b/apt/progress/old.py index 15ead890..4bd79f2e 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -18,6 +18,7 @@ # 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 @@ -39,6 +40,11 @@ __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') @@ -46,6 +52,11 @@ class OpProgress(base.OpProgress): 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.""" @@ -64,7 +75,8 @@ class FetchProgress(object): self.totalBytes = 0 self.totalItems = 0 self.currentCPS = 0 - warnings.warn("FetchProgress() is deprecated.", DeprecationWarning) + warnings.warn("apt.progress.FetchProgress is deprecated.", + DeprecationWarning, stacklevel=2) def start(self): """Called when the fetching starts.""" @@ -159,27 +171,55 @@ class TextFetchProgress(FetchProgress): return raw_input() not in ('c', 'C') -class CdromProgress(base.CdromProgress): - """Report the cdrom add progress. +class CdromProgress(object): + """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 + 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. + """Report the install progress.""" - Subclass this class to implement install progress reporting. - """ + def __init__(self): + base.InstallProgress.__init__(self) + warnings.warn("apt.progress.*InstallProgress are deprecated.", + DeprecationWarning, stacklevel=2) - startUpdate = function_deprecated_by(base.InstallProgress.start_update) - finishUpdate = function_deprecated_by(base.InstallProgress.finish_update) - updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) + 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): @@ -190,17 +230,29 @@ class InstallProgress(DumbInstallProgress, base.InstallProgress): """ selectTimeout = AttributeDeprecatedBy('select_timeout') - statusChange = function_deprecated_by(base.InstallProgress.status_change) - updateInterface = function_deprecated_by(base.InstallProgress.update_interface) - waitChild = function_deprecated_by(base.InstallProgress.wait_child) + + 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(self, debfile) + return base.InstallProgress.run(self, debfile) diff --git a/apt/progress/text.py b/apt/progress/text.py index 5e45c1db..95f18831 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -257,5 +257,3 @@ class CdromProgress(base.CdromProgress, TextProgress): return (raw_input() == '') except KeyboardInterrupt: return False - -InstallProgress = base.InstallProgress |
