-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (30 loc) · 917 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from json import loads
from os import popen
from os.path import basename
from glob import glob
from time import sleep
def compost_req(cmd_file: str) -> str:
with open(cmd_file, "r") as f:
x = f.readlines()
return " ".join(x)
def ticket_info(name: str, cmd: str):
stream = popen(cmd).read()
outputs = loads(stream)
if 'ticket' in outputs:
ticket = outputs['ticket']
else:
return
print(f">>> {basename(name)}")
# add more parameters here
para = ['usersInLineAheadOfYou', 'queueNumber', 'expectedServiceTime', 'queuePaused']
for i in para:
print(f"{i}: {ticket[i]}")
if __name__ == '__main__':
while True:
cmds = glob("commands/*")
for loc in cmds:
command = compost_req(loc)
ticket_info(loc, command)
# change it to adjust the query frequency
sleep(20)
print("-" * 100)