summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2007-08-28 10:14:02 +0200
committerMichael Vogt <egon@bottom>2007-08-28 10:14:02 +0200
commitbe3ddb25ea0baa259f20936f1d7a62cafa019b99 (patch)
tree10bf95738b6ae2050a6d95da26dacd1dab73f8a0 /apt/cache.py
parent3c2d0313a45668770e7cb2993dc092fb4e711bb7 (diff)
parentddf91759e3fabee1e0d61372247c4256758c387c (diff)
downloadpython-apt-be3ddb25ea0baa259f20936f1d7a62cafa019b99.tar.gz
* apt/debfile.py:
- added wrapper around apt_inst.debExtract() - support dictionary like access * python/apt_instmodule.cc: - added arCheckMember() * aptsources/distro.py: - throw NoDistroTemplateException if not distribution template can be found * NMU * Fix version to not use CPU and OS since it's not available on APT anymore (closes: #435653, #435674) * apt/package.py: - added Record class that can be accessed like a dictionary and return it in candidateRecord and installedRecord (thanks to Alexander Sack for discussing this with me) * doc/examples/records.py: - added example how to use the new Records class * apt/cache.py: - throw FetchCancelleException, FetchFailedException, LockFailedException exceptions when something goes wrong * aptsources/distro.py: - generalized some code, bringing it into the Distribution class, and wrote some missing methods for the DebianDistribution one (thanks to Gustavo Noronha Silva) * debian/control: - updated for python-distutils-extra (>= 1.9.0) * debian/python-apt.install: - fix i18n files * python/indexfile.cc: - increase str buffer in PackageIndexFileRepr
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 9e682bd8..65f3c9d9 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -25,6 +25,16 @@ import apt.progress
import os
import sys
+class FetchCancelledException(IOError):
+ " Exception that is thrown when the user cancels a fetch operation "
+ pass
+class FetchFailedException(IOError):
+ " Exception that is thrown when fetching fails "
+ pass
+class LockFailedException(IOError):
+ " Exception that is thrown when locking fails "
+ pass
+
class Cache(object):
""" Dictionary-like package cache
This class has all the packages that are available in it's
@@ -129,9 +139,11 @@ class Cache(object):
errMsg += "Failed to fetch %s %s\n" % (item.DescURI,item.ErrorText)
failed = True
- # we raise a exception if the download failed
- if failed:
- raise IOError, errMsg
+ # we raise a exception if the download failed or it was cancelt
+ if res == fetcher.ResultCancelled:
+ raise FetchCancelledException, errMsg
+ elif failed:
+ raise FetchFailedException, errMsg
return res
def _fetchArchives(self, fetcher, pm):
@@ -141,7 +153,7 @@ class Cache(object):
lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock"
lock = apt_pkg.GetLock(lockfile)
if lock < 0:
- raise IOError, "Failed to lock %s" % lockfile
+ raise LockFailedException, "Failed to lock %s" % lockfile
try:
# this may as well throw a SystemError exception
@@ -157,7 +169,7 @@ class Cache(object):
lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock"
lock = apt_pkg.GetLock(lockfile)
if lock < 0:
- raise IOError, "Failed to lock %s" % lockfile
+ raise LockFailedException, "Failed to lock %s" % lockfile
try:
if fetchProgress == None: