summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-27 13:57:37 +0200
committerMS <ms@taler.net>2021-05-27 13:57:37 +0200
commit51c5cc2936ce1507de1c554f4e6ec00dd5877ae9 (patch)
tree9d9d5ecdc44af639e188e2bdd68ceaa6214e81c2
parentc7670e38e8c79ff7e8df604949069fb04c43d7e6 (diff)
downloadlibeufin-51c5cc2936ce1507de1c554f4e6ec00dd5877ae9.tar.gz
libeufin-51c5cc2936ce1507de1c554f4e6ec00dd5877ae9.tar.bz2
libeufin-51c5cc2936ce1507de1c554f4e6ec00dd5877ae9.zip
cli helper function
-rwxr-xr-xcli/bin/libeufin-cli12
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/bin/libeufin-cli b/cli/bin/libeufin-cli
index c2bc5f5d..2499dd6c 100755
--- a/cli/bin/libeufin-cli
+++ b/cli/bin/libeufin-cli
@@ -12,8 +12,16 @@ from urllib.parse import urljoin
from getpass import getpass
-def tell_user(resp, withsuccess=False):
- if resp.status_code != 200:
+# Exit the program according to the HTTP status code that
+# was received.
+def managed_exit(received_status_code, expected_status_code=200):
+ if received_status_code != expected_status_code:
+ sys.exit(1)
+ sys.exit(0)
+
+
+def tell_user(resp, expected_status_code=200, withsuccess=False):
+ if resp.status_code != expected_status_code:
print(resp.content.decode("utf-8"))
return
if withsuccess: