Fix composer-cli handling of log and detail errors.
This commit is contained in:
parent
2481c486a5
commit
423e8cba88
@ -215,9 +215,14 @@ def compose_log(socket_path, api_version, args, show_json=False, testmode=0):
|
|||||||
log_size = 1024
|
log_size = 1024
|
||||||
|
|
||||||
api_route = client.api_url(api_version, "/compose/log/%s?size=%d" % (args[0], log_size))
|
api_route = client.api_url(api_version, "/compose/log/%s?size=%d" % (args[0], log_size))
|
||||||
|
try:
|
||||||
result = client.get_url_raw(socket_path, api_route)
|
result = client.get_url_raw(socket_path, api_route)
|
||||||
|
except RuntimeError as e:
|
||||||
|
print(str(e))
|
||||||
|
return 1
|
||||||
|
|
||||||
print(result)
|
print(result)
|
||||||
|
return 0
|
||||||
|
|
||||||
def compose_cancel(socket_path, api_version, args, show_json=False, testmode=0):
|
def compose_cancel(socket_path, api_version, args, show_json=False, testmode=0):
|
||||||
"""Cancel a running compose
|
"""Cancel a running compose
|
||||||
@ -311,6 +316,9 @@ def compose_details(socket_path, api_version, args, show_json=False, testmode=0)
|
|||||||
if show_json:
|
if show_json:
|
||||||
print(json.dumps(result, indent=4))
|
print(json.dumps(result, indent=4))
|
||||||
return 0
|
return 0
|
||||||
|
if "status" in result:
|
||||||
|
print(result["error"]["msg"])
|
||||||
|
return 1
|
||||||
|
|
||||||
print("%s %-8s %-15s %s %s" % (result["id"],
|
print("%s %-8s %-15s %s %s" % (result["id"],
|
||||||
result["queue_status"],
|
result["queue_status"],
|
||||||
|
@ -47,6 +47,11 @@ def get_url_raw(socket_path, url):
|
|||||||
"""
|
"""
|
||||||
http = UnixHTTPConnectionPool(socket_path)
|
http = UnixHTTPConnectionPool(socket_path)
|
||||||
r = http.request("GET", url)
|
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')
|
return r.data.decode('utf-8')
|
||||||
|
|
||||||
def get_url_json(socket_path, url):
|
def get_url_json(socket_path, url):
|
||||||
|
Loading…
Reference in New Issue
Block a user