summaryrefslogtreecommitdiffstats
path: root/cli/objects/folder.py
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-11-21 16:46:18 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2024-11-21 17:05:24 +0100
commit10a3897f92ee058155987cea23eec28b28377d4b (patch)
tree9bbc4f0bb696adbb4c97b5c524b674eff8d1a853 /cli/objects/folder.py
parentea8210a805e860154e8b0b9446bdd30043b893e6 (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/folder.py')
-rw-r--r--cli/objects/folder.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/objects/folder.py b/cli/objects/folder.py
index c4da900..2519446 100644
--- a/cli/objects/folder.py
+++ b/cli/objects/folder.py
@@ -39,7 +39,10 @@ class OgFolder():
payload['room'] = parsed_args.room_id
if parsed_args.center_id:
payload['center'] = parsed_args.center_id
- rest.post('/folder/add', payload=payload)
+ res = restest.post('/folder/add', payload=payload)
+ if not res:
+ return 1
+ return 0
@staticmethod
def update_folder(rest, args):
@@ -58,7 +61,10 @@ class OgFolder():
'id': parsed_args.id,
'name': parsed_args.name,
}
- rest.post('/folder/update', payload=payload)
+ res = rest.post('/folder/update', payload=payload)
+ if not res:
+ return 1
+ return 0
@staticmethod
def delete_folder(rest, args):
@@ -70,4 +76,7 @@ class OgFolder():
help='folder id in database')
parsed_args = parser.parse_args(args)
payload = {'id': parsed_args.id}
- rest.post('/folder/delete', payload=payload)
+ res = rest.post('/folder/delete', payload=payload)
+ if not res:
+ return 1
+ return 0