diff options
-rw-r--r-- | morphlib/remoteartifactcache.py | 10 | ||||
-rw-r--r-- | morphlib/remoteartifactcache_tests.py | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/morphlib/remoteartifactcache.py b/morphlib/remoteartifactcache.py index 649ff49e..aaab4a3c 100644 --- a/morphlib/remoteartifactcache.py +++ b/morphlib/remoteartifactcache.py @@ -15,6 +15,7 @@ import cliapp +import logging import urllib2 import urlparse @@ -69,24 +70,27 @@ class RemoteArtifactCache(object): def get(self, artifact): try: return self._get_file(artifact.basename()) - except: + except urllib2.URLError, e: + logging.error(str(e)) raise GetError(self, artifact) def get_artifact_metadata(self, artifact, name): try: return self._get_file(artifact.metadata_basename(name)) - except: + except urllib2.URLError, e: + logging.error(str(e)) raise GetArtifactMetadataError(self, artifact, name) def get_source_metadata(self, source, cachekey, name): filename = '%s.%s' % (cachekey, name) try: return self._get_file(filename) - except: + except urllib2.URLError: raise GetSourceMetadataError(self, source, cachekey, name) def _has_file(self, filename): # pragma: no cover url = self._request_url(filename) + logging.debug('RemoteArtifactCache._has_file: url=%s' % url) request = HeadRequest(url) try: urllib2.urlopen(request) diff --git a/morphlib/remoteartifactcache_tests.py b/morphlib/remoteartifactcache_tests.py index b7f10450..201cfc50 100644 --- a/morphlib/remoteartifactcache_tests.py +++ b/morphlib/remoteartifactcache_tests.py @@ -16,6 +16,7 @@ import StringIO import unittest +import urllib2 import morphlib @@ -76,7 +77,7 @@ class RemoteArtifactCacheTests(unittest.TestCase): if filename in self.existing_files: return StringIO.StringIO('%s' % filename) else: - raise Exception('foo') + raise urllib2.URLError('foo') def test_sets_server_url(self): self.assertEqual(self.cache.server_url, self.server_url) |