summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2007-06-28 15:40:29 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2007-06-28 15:40:29 +0200
commit2597f1449e1b81b0a626390d67c35cd6c8f863b9 (patch)
treec4d88026abed051f18a92fb9afd9a8d31389911a /apt
parent39910144460cafcc27d69026fd680fc8bd19c447 (diff)
downloadpython-apt-2597f1449e1b81b0a626390d67c35cd6c8f863b9.tar.gz
* python/cache.py:
- throw FetchCanceltException, FetchFailedException, LockFailedException exceptions when something goes wrong
Diffstat (limited to 'apt')
-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..31919e79 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -25,6 +25,16 @@ import apt.progress
import os
import sys
+class FetchCanceltException(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 FetchCanceltException, 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: