From b55b86d0b324449d7137e6859cdd39757f979532 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 26 Jul 2018 10:28:54 -0700 Subject: [PATCH] Update modules.py to use new handle_api_result Use the new function to properly handle error responses for all the commands. --- src/composer/cli/modules.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/composer/cli/modules.py b/src/composer/cli/modules.py index 25ad1e04..20c119cf 100644 --- a/src/composer/cli/modules.py +++ b/src/composer/cli/modules.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 modules_help +from composer.cli.utilities import handle_api_result def modules_cmd(opts): """Process modules commands @@ -39,10 +38,10 @@ def modules_cmd(opts): api_route = client.api_url(opts.api_version, "/modules/list") result = client.get_url_json(opts.socket, api_route) - if opts.json: - print(json.dumps(result, indent=4)) - return 0 + (rc, exit_now) = handle_api_result(result, opts.show_json) + if exit_now: + return rc print("Modules:\n" + "\n".join([" "+r["name"] for r in result["modules"]])) - return 0 + return rc