summaryrefslogtreecommitdiff
path: root/morphlib/plugins
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-18 16:56:07 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-19 09:51:18 +0000
commit9dfed63d574ad68e7a22c98ef9aac1f2a3bd172b (patch)
tree2f6f959f143e0ba5a17c9c1243c2fc93124e7804 /morphlib/plugins
parentec6710062a9ea139b165d2b96466e1b1b4991378 (diff)
downloadmorph-9dfed63d574ad68e7a22c98ef9aac1f2a3bd172b.tar.gz
Raise exception if show-build-log doesn't find the build log
Previously it would print nothing and then exit with success. Better to tell the user that an error occurred. Example of the new error: ERROR: No build log for artifact 6fb39673b8f9a1c9848063f5132aa958ffa75f2be61a8dde68ebb11f5a3c4a5f found on cache server http://cache.baserock.org:8080/ Change-Id: Icf8ceef60eb497ff90e00391d442a394e3d76f10
Diffstat (limited to 'morphlib/plugins')
-rw-r--r--morphlib/plugins/show_build_log_plugin.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/morphlib/plugins/show_build_log_plugin.py b/morphlib/plugins/show_build_log_plugin.py
index 6f22036a..38b62540 100644
--- a/morphlib/plugins/show_build_log_plugin.py
+++ b/morphlib/plugins/show_build_log_plugin.py
@@ -86,11 +86,20 @@ class ShowBuildLog(cliapp.Plugin):
if cache_key:
url = urlparse.urljoin(artifact_cache_server,
'/1.0/artifacts?filename=%s.build-log' % source.cache_key)
- build_log = urllib.urlopen(url)
- build_output = []
- for line in build_log:
- build_output.append(str(line))
- self.app.output.write(''.join(build_output))
+ response = urllib.urlopen(url)
+ if response.getcode() == 200:
+ build_output = []
+ for line in response:
+ build_output.append(str(line))
+ self.app.output.write(''.join(build_output))
+ elif response.getcode() == 404:
+ raise cliapp.AppException(
+ 'No build log for artifact %s found on cache server %s' %
+ (source.cache_key, artifact_cache_server))
+ else:
+ raise cliapp.AppException(
+ 'Error connecting to cache server %s: %s' %
+ (artifact_cache_server, response.getcode()))
else:
raise cliapp.AppException('Component not found in the given '
'system.')