Update modules.py to use new handle_api_result

Use the new function to properly handle error responses for all the
commands.

(cherry picked from commit b55b86d0b3)
This commit is contained in:
Brian C. Lane 2018-07-26 10:28:54 -07:00
parent 35e2471e41
commit 6614f65198
1 changed files with 5 additions and 6 deletions

View File

@ -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