diff --git a/src/composer/cli/compose.py b/src/composer/cli/compose.py index 3d5aba35..d7e45897 100644 --- a/src/composer/cli/compose.py +++ b/src/composer/cli/compose.py @@ -215,9 +215,14 @@ def compose_log(socket_path, api_version, args, show_json=False, testmode=0): log_size = 1024 api_route = client.api_url(api_version, "/compose/log/%s?size=%d" % (args[0], log_size)) - result = client.get_url_raw(socket_path, api_route) + try: + result = client.get_url_raw(socket_path, api_route) + except RuntimeError as e: + print(str(e)) + return 1 print(result) + return 0 def compose_cancel(socket_path, api_version, args, show_json=False, testmode=0): """Cancel a running compose @@ -311,6 +316,9 @@ def compose_details(socket_path, api_version, args, show_json=False, testmode=0) if show_json: print(json.dumps(result, indent=4)) return 0 + if "status" in result: + print(result["error"]["msg"]) + return 1 print("%s %-8s %-15s %s %s" % (result["id"], result["queue_status"], diff --git a/src/composer/http_client.py b/src/composer/http_client.py index d4e5d918..7178851d 100644 --- a/src/composer/http_client.py +++ b/src/composer/http_client.py @@ -47,6 +47,11 @@ def get_url_raw(socket_path, url): """ http = UnixHTTPConnectionPool(socket_path) r = http.request("GET", url) + if r.status == 400: + err = json.loads(r.data.decode("utf-8")) + if "status" in err and err["status"] == False: + raise RuntimeError(err["error"]["msg"]) + return r.data.decode('utf-8') def get_url_json(socket_path, url):