diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-11-21 16:46:18 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2024-11-21 17:05:24 +0100 |
commit | 10a3897f92ee058155987cea23eec28b28377d4b (patch) | |
tree | 9bbc4f0bb696adbb4c97b5c524b674eff8d1a853 /cli/objects/scopes.py | |
parent | ea8210a805e860154e8b0b9446bdd30043b893e6 (diff) |
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.
Diffstat (limited to 'cli/objects/scopes.py')
-rw-r--r-- | cli/objects/scopes.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/objects/scopes.py b/cli/objects/scopes.py index bfa3f94..88f5521 100644 --- a/cli/objects/scopes.py +++ b/cli/objects/scopes.py @@ -57,8 +57,8 @@ class OgScope(): for ip in parsed_args.client_ip: ips.add(ip) - r = rest.get('/scopes') - json_data = json.loads(r.text) + res = rest.get('/scopes') + json_data = json.loads(res.text) if parsed_args.name: path = _get_client_path(json_data, None, 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 + print_json(res.text) + return 0 |