summaryrefslogtreecommitdiff
path: root/morphlib/remoteartifactcache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-20 15:21:47 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-06-22 11:39:52 +0100
commitb44537d279a8d5e49c2f67f08840b6dee120e695 (patch)
treef1685422deba856a61b3bfe18cd0f7a640d18e01 /morphlib/remoteartifactcache.py
parent1133dcef64ae71845bbec741a7b061858e7fa731 (diff)
downloadmorph-b44537d279a8d5e49c2f67f08840b6dee120e695.tar.gz
Handle only the urllib2.URLError exceptions
Handling all exceptions in a way that assumes they're all related to the URL fetching hides unrelated errors, such as missing imports, or bad types, or such. Also, add more logging for debugging.
Diffstat (limited to 'morphlib/remoteartifactcache.py')
-rw-r--r--morphlib/remoteartifactcache.py10
1 files changed, 7 insertions, 3 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)