Added status report

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2020-01-16 02:23:47 +00:00
parent 18898125ac
commit 3facc580a6

View file

@ -102,7 +102,12 @@ try:
action = "get"
get = match.group(2)
else:
print("WARNING: Recived invalid package")
match = re.match(r"(status) (n-pole|s-pole|[ew]\d{3}[ns]\d{2})", msg)
if match != None:
action = "status"
name = match.group(2)
else:
print("WARNING: Recived invalid package")
if action == "set":
if verbose:
@ -220,6 +225,33 @@ try:
print("Asigning job on tile " + tile)
c.send(tile.encode())
elif action == "status":
if name == "n-pole" or name == "s-pole":
c.send(state[name]["status"].encode())
else:
match = re.match(r"([ew])(\d{3})([ns])(\d{2})", name)
ew = match.group(1)
ew_val = int(match.group(2))
ns = match.group(3)
ns_val = int(match.group(4))
ew_val_major = int(ew_val / 10) * 10
if ew == "w":
if ew_val_major != ew_val:
ew_val_major += 10
ns_val_major = int(ns_val / 10) * 10
if ns == "s":
if ns_val_major != ns_val:
ns_val_major += 10
name_major = ew + norm(ew_val_major, 3) + ns + norm(ns_val_major, 2)
if not name_major in state:
c.send("pending".encode())
elif not name in state[name_major]:
c.send("pending".encode())
else:
c.send(state[name_major][name]["status"].encode())
c.close()
except IOError:
print("WARNING: Recived invalid package")