From 3d0aff3d1d47a053a678ecbec69d585cf1bbb275 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 8 Nov 2024 10:06:00 +0100 Subject: cli: ensure the program returns 0 on success and 1 on error propagate a returncode in each operation and make it the returncode of the program. Prevent sys.exit calls in post(), get() and delete() request handlers to enable cleanup code and error handling. Keep a basic error log inside the request functions if the connection can't be established or if the response contains an error code. --- cli/objects/scopes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'cli/objects/scopes.py') diff --git a/cli/objects/scopes.py b/cli/objects/scopes.py index 548b93c..5779f78 100644 --- a/cli/objects/scopes.py +++ b/cli/objects/scopes.py @@ -57,7 +57,7 @@ class OgScope(): for ip in parsed_args.client_ip: ips.add(ip) - r = rest.get('/scopes') + res = rest.get('/scopes') json_data = json.loads(r.text) if parsed_args.name: @@ -71,8 +71,7 @@ class OgScope(): path = _get_client_path(json_data, client_ip, None) for i, item in enumerate(path): print(' ' * i + item) - return None else: print_json(r.text) - return None + return 0 -- cgit v1.2.3-18-g5258