From 4fcfe8b00e52a21c2144877fb631a70d6c75fd19 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 22 Aug 2009 22:56:18 +0200 Subject: apt/cache.py: Convert argument to str in __getitem__() (Closes: #542965). --- apt/cache.py | 1 + 1 file changed, 1 insertion(+) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 756f9ba9..446cfae7 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -135,6 +135,7 @@ class Cache(object): return self._weakref[key] except KeyError: if key in self._set: + key = str(key) pkg = self._weakref[key] = Package(self, self._cache[key]) return pkg else: -- cgit v1.2.3 From 8c708ec819333e0360b815bbbb504460e9f15d9a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 24 Aug 2009 13:40:43 +0200 Subject: * apt/cache.py: - add actiongroup() method (backport from 0.7.92) --- apt/cache.py | 9 +++++++++ debian/changelog | 2 ++ 2 files changed, 11 insertions(+) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index bb396d59..d46cd078 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -335,6 +335,15 @@ class Cache(object): a signal then """ self._runCallbacks("cache_pre_change") + def actiongroup(self): + """Return an ActionGroup() object for the current cache. + + Action groups can be used to speedup actions. The action group is + active as soon as it is created, and disabled when the object is + deleted or when release() is called. + """ + return apt_pkg.GetPkgActionGroup(self._depcache) + def connect(self, name, callback): """ connect to a signal, currently only used for cache_{post,pre}_{changed,open} """ diff --git a/debian/changelog b/debian/changelog index 3f22d113..22d14fa7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ python-apt (0.7.12.2) UNRELEASED; urgency=low - add optional pulseIntevall option to "update()" * po/python-apt.pot: - refreshed + * apt/cache.py: + - add actiongroup() method (backport from 0.7.92) [ Julian Andres Klode ] * apt/package.py: -- cgit v1.2.3 From 0aa3f4f3ce25a499a332c23f9493e629f30013dc Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 2 Sep 2009 20:45:52 +0200 Subject: re-work the logic in commit() to fail if installArchives() returns a unexpected result --- apt/cache.py | 6 +++++- debian/changelog | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index 828b167b..bb944041 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -314,8 +314,12 @@ class Cache(object): res = self.installArchives(pm, installProgress) if res == pm.ResultCompleted: break - if res == pm.ResultFailed: + elif res == pm.ResultFailed: raise SystemError("installArchives() failed") + elif res == pm.ResultIncomplete: + pass + else: + raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.Shutdown() return (res == pm.ResultCompleted) diff --git a/debian/changelog b/debian/changelog index bfba50e0..ada400bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low [ Michael Vogt ] * apt/cache.py: - add actiongroup() method (backport from 0.7.92) + - re-work the logic in commit() to fail if installArchives() returns + a unexpected result [ Sebastian Heinlein ] * apt/package.py: -- cgit v1.2.3 From 2a5bb5071e4046773407bfb47511c72dcd1aa887 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 15 Sep 2009 15:17:13 +0200 Subject: apt/cache.py: Add raiseOnError option to Cache.update() (Closes: #545474) --- apt/cache.py | 11 +++++++++-- debian/changelog | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'apt/cache.py') diff --git a/apt/cache.py b/apt/cache.py index bb944041..fa6c404c 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -270,7 +270,7 @@ class Cache(object): providers.append(pkg) return providers - def update(self, fetchProgress=None, pulseInterval=0): + def update(self, fetchProgress=None, pulseInterval=0, raiseOnError=False): " run the equivalent of apt-get update " lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" lock = apt_pkg.GetLock(lockfile) @@ -280,7 +280,14 @@ class Cache(object): try: if fetchProgress is None: fetchProgress = apt.progress.FetchProgress() - return self._cache.Update(fetchProgress, self._list, pulseInterval) + res = self._cache.Update(fetchProgress, self._list, pulseInterval) + + if res == 2 and raiseOnError: + raise FetchCancelledException() + elif res == 1 and raiseOnError: + raise FetchFailedException() + else: + return res finally: os.close(lock) diff --git a/debian/changelog b/debian/changelog index 51946519..24ce6245 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ python-apt (0.7.13.3) UNRELEASED; urgency=low * python/depcache.cc: - Make ActionGroups context managers so apt.Cache.actiongroup() has the same behavior as in 0.7.92 + * apt/cache.py: + - Add raiseOnError option to Cache.update() (Closes: #545474) * apt/package.py: - Use the source version instead of the binary version in fetch_source(). * apt/progress/__init__.py: -- cgit v1.2.3