From e46cd506075aa591a2712af8c9fa272ca652d998 Mon Sep 17 00:00:00 2001 From: fly Date: Wed, 10 Mar 2021 19:21:18 +0000 Subject: [PATCH] Added api support for set-status Signed-off-by: fly --- set-status.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/set-status.py b/set-status.py index fbe2d2d..3d5a329 100755 --- a/set-status.py +++ b/set-status.py @@ -22,6 +22,8 @@ from common import send_status host = socket.gethostname() port = 12345 +api = None +apt_token = None tile = "" status = "" @@ -35,6 +37,12 @@ while i < argc: elif sys.argv[i] == "--host": i += 1 host = sys.argv[i] + elif sys.argv[i] == "-a" or sys.argv[i] == "--api": + i += 1 + api = sys.argv[i] + elif sys.argv[i] == "-t" or sys.argv[i] == "--api-token": + i += 1 + api_token = sys.argv[i] elif sys.argv[i] == "-h" or sys.argv[i] == "--help": print("usage: set-status.py [OPTIONS]") print("Manually set a tile status") @@ -51,6 +59,8 @@ while i < argc: print("OPTIONS") print(" , --host Manager host") print(" , --port Manager port") + print(" -a, --api Manager api url") + print(" -t, --api-token Manager api token") print(" -h, --help Shows this help and exit") sys.exit(0) else: @@ -81,6 +91,13 @@ if status == "": print("ERROR: No status given") sys.exit(1) -send_status(tile, status, host, port) +if api != None and api_token == None: + print("Error: API given but no token") + sys.exit(1) + +if api == None: + send_status(tile, status, host, port) +else: + api_send_status(tile, status, api, api_token) print("Status set successfully")