Added api support for set-status

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2021-03-10 19:21:18 +00:00
parent 3588e6b3ac
commit e46cd50607

View file

@ -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 <tile> <status> [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")