diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-09-15 15:17:13 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-09-15 15:17:13 +0200 |
| commit | 2a5bb5071e4046773407bfb47511c72dcd1aa887 (patch) | |
| tree | 4354eaabea5331627ca7228db1d8d8d19226497e | |
| parent | 92ee136013b7432b0e21694098b17f3d0a4f7be5 (diff) | |
| download | python-apt-2a5bb5071e4046773407bfb47511c72dcd1aa887.tar.gz | |
apt/cache.py: Add raiseOnError option to Cache.update() (Closes: #545474)
| -rw-r--r-- | apt/cache.py | 11 | ||||
| -rw-r--r-- | debian/changelog | 2 |
2 files changed, 11 insertions, 2 deletions
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: |
