summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-09-16 20:05:46 +0200
committerJulian Andres Klode <jak@debian.org>2009-09-16 20:05:46 +0200
commita7217b885beff13462bbb793eac42d28c53752f8 (patch)
treee141cd0d0e644e7cf4f79fea34ba9bf8977801b8 /apt/cache.py
parent8600d4c44a5b9f75887da6e12acea622caef8c76 (diff)
parentbe85eeaeadf8b93021413ab7ed79e639b65102a6 (diff)
downloadpython-apt-a7217b885beff13462bbb793eac42d28c53752f8.tar.gz
Merge 0.7.13.0 - 0.7.13.3 from unstable.
* 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 * apt/progress/__init__.py: - catch exceptions in pm.DoInstall() * apt/package.py: - Export if a package is an essential one (Closes: #543428) * 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: - Correctly ignore ECHILD by checking before EINTR (Closes: #546007) * apt/cache.py: - Convert argument to str in __getitem__() (Closes: #542965).
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/apt/cache.py b/apt/cache.py
index eff07ef8..bda08a24 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -71,7 +71,7 @@ class Cache(object):
self._check_and_create_required_dirs(rootdir)
# Call InitSystem so the change to Dir::State::Status is actually
# recognized (LP: #320665)
- apt_pkg.InitSystem()
+ apt_pkg.init_system()
self.open(progress)
def _check_and_create_required_dirs(self, rootdir):
@@ -139,6 +139,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:
@@ -278,7 +279,8 @@ class Cache(object):
return providers
@deprecated_args
- def update(self, fetch_progress=None, pulse_interval=0):
+ def update(self, fetch_progress=None, pulse_interval=0,
+ raise_on_error=True):
"""Run the equivalent of apt-get update.
The first parameter *fetch_progress* may be set to an instance of
@@ -294,8 +296,14 @@ class Cache(object):
try:
if fetch_progress is None:
fetch_progress = apt.progress.FetchProgress()
- return self._cache.update(fetch_progress, self._list,
+ res = self._cache.update(fetch_progress, self._list,
pulse_interval)
+ if res == apt_pkg.Acquire.result_cancelled and raise_on_error:
+ raise FetchCancelledException()
+ if res == apt_pkg.Acquire.result_failed and raise_on_error:
+ raise FetchFailedException()
+ else:
+ return res
finally:
os.close(lock)
@@ -352,8 +360,12 @@ class Cache(object):
res = self.install_archives(pm, install_progress)
if res == pm.result_completed:
break
- if res == pm.result_failed:
+ elif res == pm.result_failed:
raise SystemError("installArchives() failed")
+ elif res == pm.result_incomplete:
+ pass
+ else:
+ raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res)
# reload the fetcher for media swaping
fetcher.shutdown()
return (res == pm.result_completed)