From 1fff409465af468585b0a925e00c1fa73fe6d9ae Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 26 Jul 2018 10:52:27 -0700 Subject: [PATCH] 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 642f117d54619e5bfef1d5130756b70e5445d17e) --- src/composer/cli/status.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/composer/cli/status.py b/src/composer/cli/status.py index 640a23a0..09afee93 100644 --- a/src/composer/cli/status.py +++ b/src/composer/cli/status.py @@ -17,10 +17,9 @@ import logging log = logging.getLogger("composer-cli") -import json - from composer import http_client as client from composer.cli.help import status_help +from composer.cli.utilities import handle_api_result def status_cmd(opts): """Process status commands @@ -38,9 +37,9 @@ def status_cmd(opts): return 1 result = client.get_url_json(opts.socket, "/api/status") - if opts.json: - print(json.dumps(result, indent=4)) - return 0 + (rc, exit_now) = handle_api_result(result, opts.json) + if exit_now: + return rc print("API server status:") print(" Database version: " + result["db_version"]) @@ -54,4 +53,4 @@ def status_cmd(opts): print("Error messages:") print("\n".join([" " + r for r in result["msgs"]])) - return 0 + return rc