summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-20 17:30:04 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-02-20 17:38:48 +0000
commit620e088353ddd378316c36d72c81651a1baa3dbe (patch)
tree2c3c2bbbb97a64cc617e5d23c5dc25b01768e471 /morphlib
parentc7bd647c9c934e1c5082ed841d07cef3af4dfe30 (diff)
downloadmorph-620e088353ddd378316c36d72c81651a1baa3dbe.tar.gz
Delay bundle and base URL errors until we are sure all of them failed.
This is done to not print confusing errors in situations where one of the bundles or base URLs works and everything is fine. If all of them are failing though, we now print all the error messages in order to give users an overview over what might have gone wrong.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/sourcemanager.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/morphlib/sourcemanager.py b/morphlib/sourcemanager.py
index 926f1d0d..43fd33e3 100644
--- a/morphlib/sourcemanager.py
+++ b/morphlib/sourcemanager.py
@@ -122,18 +122,14 @@ class SourceManager(object):
self.msg('Setting origin to %s' % repo_url)
morphlib.git.set_remote(cached_repo, 'origin',
repo_url, self.msg)
- return cached_repo
+ return cached_repo, None
except morphlib.execute.CommandFailure, e: # pragma: no cover
- self.msg('Unable to extract bundle %s: %s' %
- (bundle, e))
- return None
+ return None, 'Unable to extract bundle %s: %s' % (bundle,
+ e)
except morphlib.execute.CommandFailure, e: # pragma: no cover
- self.msg('Unable to fetch bundle %s: %s' %
- (bundle_url, e))
- return None
+ return None, 'Unable to fetch bundle %s: %s' % (bundle, e)
except urllib2.URLError, e:
- self.msg('Unable to fetch bundle %s: %s' % (bundle_url, e))
- return None
+ return None, 'Unable to fetch bundle %s: %s' % (bundle_url, e)
def _cache_repo_from_url(self, repo_url):
# quote the URL and calculate the location for the cached repo
@@ -143,16 +139,14 @@ class SourceManager(object):
if os.path.exists(cached_repo): # pragma: no cover
# the cache location exists, assume this is what we want
self.msg('Using cached clone %s of %s' % (cached_repo, repo_url))
- return cached_repo
else:
# bundle server did not have a bundle for the repo
self.msg('Cloning %s into %s' % (repo_url, cached_repo))
try:
morphlib.git.clone(cached_repo, repo_url, self.msg)
- return cached_repo
+ return cached_repo, None
except morphlib.execute.CommandFailure, e:
- self.msg('Failed to clone from %s: %s' % (repo_url, e))
- return None
+ return None, 'Failed to clone from %s: %s' % (repo_url, e)
def _cache_repo_from_base_urls(self, repo, ref):
self.msg('Checking repository %s' % repo)
@@ -166,6 +160,7 @@ class SourceManager(object):
for x in self.settings['git-base-url']]
cached_repo = None
+ errors = []
# check if we have a cached version of the repo
for repo_url in repo_urls:
@@ -180,17 +175,22 @@ class SourceManager(object):
server = fixup_url(self.settings['bundle-server'])
for repo_url in repo_urls:
- cached_repo = self._cache_repo_from_bundle(server, repo_url)
+ cached_repo, error = self._cache_repo_from_bundle(server,
+ repo_url)
if cached_repo:
break
+ else:
+ errors.append(error)
# second pass, try cloning from base URLs directly
if not cached_repo:
# try all URLs to find or obtain a cached clone of the repo
for repo_url in repo_urls:
- cached_repo = self._cache_repo_from_url(repo_url)
+ cached_repo, error = self._cache_repo_from_url(repo_url)
if cached_repo:
break
+ else:
+ errors.append(error)
if cached_repo:
# we have a cached version of the repo now
@@ -211,6 +211,12 @@ class SourceManager(object):
cached_repo)
else: # pragma: no cover
# cloning using all individual base URLs failed
+
+ # print all the errors at once to give the user an overview
+ # over what went wrong in which order
+ for error in errors:
+ self.msg(error)
+
self.indent_less()
raise RepositoryFetchError(repo)