Added api support for set-status
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
3588e6b3ac
commit
e46cd50607
1 changed files with 18 additions and 1 deletions
|
@ -22,6 +22,8 @@ from common import send_status
|
||||||
|
|
||||||
host = socket.gethostname()
|
host = socket.gethostname()
|
||||||
port = 12345
|
port = 12345
|
||||||
|
api = None
|
||||||
|
apt_token = None
|
||||||
tile = ""
|
tile = ""
|
||||||
status = ""
|
status = ""
|
||||||
|
|
||||||
|
@ -35,6 +37,12 @@ while i < argc:
|
||||||
elif sys.argv[i] == "--host":
|
elif sys.argv[i] == "--host":
|
||||||
i += 1
|
i += 1
|
||||||
host = sys.argv[i]
|
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":
|
elif sys.argv[i] == "-h" or sys.argv[i] == "--help":
|
||||||
print("usage: set-status.py <tile> <status> [OPTIONS]")
|
print("usage: set-status.py <tile> <status> [OPTIONS]")
|
||||||
print("Manually set a tile status")
|
print("Manually set a tile status")
|
||||||
|
@ -51,6 +59,8 @@ while i < argc:
|
||||||
print("OPTIONS")
|
print("OPTIONS")
|
||||||
print(" , --host Manager host")
|
print(" , --host Manager host")
|
||||||
print(" , --port Manager port")
|
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")
|
print(" -h, --help Shows this help and exit")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
|
@ -81,6 +91,13 @@ if status == "":
|
||||||
print("ERROR: No status given")
|
print("ERROR: No status given")
|
||||||
sys.exit(1)
|
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")
|
print("Status set successfully")
|
||||||
|
|
Loading…
Reference in a new issue