diff options
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/cache.py | 6 | ||||
| -rw-r--r-- | apt/package.py | 50 | ||||
| -rw-r--r-- | apt/progress/old.py | 16 |
3 files changed, 53 insertions, 19 deletions
diff --git a/apt/cache.py b/apt/cache.py index 40808abd..f507863c 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -69,6 +69,9 @@ class Cache(object): # create required dirs/files when run with special rootdir # automatically self._check_and_create_required_dirs(rootdir) + # Call InitSystem so the change to Dir::State::Status is actually + # recognized (LP: #320665) + apt_pkg.InitSystem() self.open(progress) def _check_and_create_required_dirs(self, rootdir): @@ -106,9 +109,6 @@ class Cache(object): progress = apt.progress.text.OpProgress() self._run_callbacks("cache_pre_open") - # Make changes to Dir::State::Status work again, by reinitialising - # the system. - apt_pkg.init_system() self._cache = apt_pkg.Cache(progress) self._depcache = apt_pkg.DepCache(self._cache) self._records = apt_pkg.PackageRecords(self._cache) diff --git a/apt/package.py b/apt/package.py index 1307ca3e..f8e1354b 100644 --- a/apt/package.py +++ b/apt/package.py @@ -33,6 +33,11 @@ except ImportError: # (for Python < 2.6) pylint: disable-msg=C0103 Sequence = Mapping = object +try: + from collections import Sequence +except ImportError: + Sequence = object + import apt_pkg import apt.progress.text from apt_pkg import gettext as _ @@ -40,7 +45,7 @@ from apt.deprecation import (function_deprecated_by, AttributeDeprecatedBy, deprecated_args) __all__ = ('BaseDependency', 'Dependency', 'Origin', 'Package', 'Record', - 'Version') + 'Version', 'VersionList') def _file_is_same(path, size, md5): @@ -200,22 +205,47 @@ class Version(object): self.package = package self._cand = cand - def __eq__(self, other): + def _cmp(self, other): try: - return self._cand.id == other._cand.id + return apt_pkg.Version_compare(self._cand.ver_str, other.version) except AttributeError: - return apt_pkg.version_compare(self.version, other) == 0 - except Exception: - return False + return apt_pkg.Version_compare(self._cand.ver_str, other) + + def __eq__(self, other): + try: + return self._cmp(other) == 0 + except TypeError: + return NotImplemented + + def __ge__(self, other): + try: + return self._cmp(other) >= 0 + except TypeError: + return NotImplemented def __gt__(self, other): - return apt_pkg.version_compare(self.version, other.version) > 0 + try: + return self._cmp(other) > 0 + except TypeError: + return NotImplemented + + def __le__(self, other): + try: + return self._cmp(other) <= 0 + except TypeError: + return NotImplemented def __lt__(self, other): - return apt_pkg.version_compare(self.version, other.version) < 0 + try: + return self._cmp(other) < 0 + except TypeError: + return NotImplemented def __ne__(self, other): - return not self.__eq__(other) + try: + return self._cmp(other) != 0 + except TypeError: + return NotImplemented def __hash__(self): return self._cand.hash @@ -610,8 +640,6 @@ class Package(object): This property is writeable to allow you to set the candidate version of the package. Just assign a Version() object, and it will be set as the candidate version. - - .. versionadded:: 0.7.9 """ cand = self._pcache._depcache.get_candidate_ver(self._pkg) if cand is not None: diff --git a/apt/progress/old.py b/apt/progress/old.py index 05597481..88957272 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -315,14 +315,20 @@ class InstallProgress(DumbInstallProgress): while True: try: select.select([self.statusfd], [], [], self.select_timeout) - except select.error, e: - if e[0] != errno.EINTR: + except select.error, (errno_, errstr): + if errno_ != errno.EINTR: raise self.update_interface() - (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) - if pid == self.child_pid: - break + 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): |
