Update status.py to use new handle_api_result
Use the new function to properly handle error responses for all the
commands.
(cherry picked from commit 642f117d54
)
This commit is contained in:
parent
2ec00fb5ce
commit
1fff409465
@ -17,10 +17,9 @@
|
|||||||
import logging
|
import logging
|
||||||
log = logging.getLogger("composer-cli")
|
log = logging.getLogger("composer-cli")
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from composer import http_client as client
|
from composer import http_client as client
|
||||||
from composer.cli.help import status_help
|
from composer.cli.help import status_help
|
||||||
|
from composer.cli.utilities import handle_api_result
|
||||||
|
|
||||||
def status_cmd(opts):
|
def status_cmd(opts):
|
||||||
"""Process status commands
|
"""Process status commands
|
||||||
@ -38,9 +37,9 @@ def status_cmd(opts):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
result = client.get_url_json(opts.socket, "/api/status")
|
result = client.get_url_json(opts.socket, "/api/status")
|
||||||
if opts.json:
|
(rc, exit_now) = handle_api_result(result, opts.json)
|
||||||
print(json.dumps(result, indent=4))
|
if exit_now:
|
||||||
return 0
|
return rc
|
||||||
|
|
||||||
print("API server status:")
|
print("API server status:")
|
||||||
print(" Database version: " + result["db_version"])
|
print(" Database version: " + result["db_version"])
|
||||||
@ -54,4 +53,4 @@ def status_cmd(opts):
|
|||||||
print("Error messages:")
|
print("Error messages:")
|
||||||
print("\n".join([" " + r for r in result["msgs"]]))
|
print("\n".join([" " + r for r in result["msgs"]]))
|
||||||
|
|
||||||
return 0
|
return rc
|
||||||
|
Loading…
Reference in New Issue
Block a user