From 10a3897f92ee058155987cea23eec28b28377d4b Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 21 Nov 2024 16:46:18 +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/live.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cli/objects/live.py') diff --git a/cli/objects/live.py b/cli/objects/live.py index c90a4c2..7a057bf 100644 --- a/cli/objects/live.py +++ b/cli/objects/live.py @@ -13,5 +13,8 @@ class OgLive(): @staticmethod def list_live(rest): - r = rest.get('/oglive/list') - print_json(r.text) + res = rest.get('/oglive/list') + if not res: + return 1 + print_json(res.text) + return 0 -- cgit v1.2.3-18-g5258