Handle packaged state

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2020-01-23 14:02:27 +00:00
parent d05795a023
commit 711cec4f04
2 changed files with 65 additions and 9 deletions

View file

@ -59,7 +59,7 @@ while i < argc:
first = 2
tile = match.group(0)
elif first == 2:
match = re.match(r"(done|pending|rebuild|skip)", sys.argv[i])
match = re.match(r"(done|pending|rebuild|skip|packaged)", sys.argv[i])
if match == None:
print("ERROR: Invalid status " + sys.argv[i])
sys.exit(1)

View file

@ -73,7 +73,7 @@ def set_state(state, name, status):
if verbose:
print(name + " set status to " + status)
if status == "started" or status == "done" or status == "rebuild" or status == "skip" or status == "pending":
if status == "started" or status == "done" or status == "rebuild" or status == "skip" or status == "pending" or status == "packaged":
if name == "n-pole" or name == "s-pole":
if not name in state:
state[name] = {}
@ -111,9 +111,11 @@ def set_state(state, name, status):
state[name_major]["pending"] = 0
for tile in state[name_major]:
# Filter status of name_major
if tile != "done" and tile != "started" and tile != "pending" and tile != "status" and tile != "rebuild" and tile != "skip":
if tile != "done" and tile != "started" and tile != "pending" and tile != "status" and tile != "rebuild" and tile != "skip" and tile != "packaged":
state[name_major][state[name_major][tile]["status"]] += 1
if state[name_major]["done"] == 100:
if state[name_major]["packaged"] == 100:
state[name_major]["status"] = "packaged"
elif state[name_major]["done"] == 100:
state[name_major]["status"] = "done"
elif state[name_major]["started"] > 0:
state[name_major]["status"] = "started"
@ -150,16 +152,19 @@ try:
msg = c.recv(128)
msg = msg.decode()
match = re.match(r"(set) (n-pole|s-pole|[ew]\d{3}[ns]\d{2}) (done|started|rebuild|skip|pending)", msg)
match = re.match(r"(set) (n-pole|s-pole|[ew]\d{3}[ns]\d{2}) (done|started|rebuild|skip|pending|packaged)", msg)
if match != None:
action = "set"
name = match.group(2)
status = match.group(3)
else:
match = re.match(r"(get) (started|rebuild|skip|pending)", msg)
match = re.match(r"(get) (started|rebuild|skip|pending|done)", msg)
if match != None:
action = "get"
get = match.group(2)
if match.group(2) == "done":
action = "get-done"
else:
action = "get-job"
get = match.group(2)
else:
match = re.match(r"(status) (n-pole|s-pole|[ew]\d{3}[ns]\d{2})", msg)
if match != None:
@ -171,7 +176,7 @@ try:
if action == "set":
state = set_state(state, name, status)
elif action == "get":
elif action == "get-job":
tile = ""
# Build poles first
if not "n-pole" in state or ("n-pole" in state and state["n-pole"]["status"] == get):
@ -231,6 +236,57 @@ try:
print("Asigning job on tile " + tile)
c.send(tile.encode())
elif action == "get-done":
tile = ""
if "n-pole" in state and state["n-pole"]["status"] == "done":
tile = "n-pole"
elif "s-pole" in state and state["s-pole"]["status"] == "done":
tile = "s-pole"
else:
ii = -8
while ii < 8 and tile == "":
i = ii * 10
jj = -18
while jj < 18 and tile == "":
j = jj * 10
if i >= 0:
ns = "n"
else:
ns = "s"
if j >= 0:
ew = "e"
else:
ew = "w"
name = ew + norm(abs(j), 3) + ns + norm(abs(i), 2)
if name in state and state[name]["status"] != "packaged":
if ns == "s":
ns_step = -1
else:
ns_step = 1
if ew == "w":
ew_step = -1
else:
ew_step = 1
j = abs(j)
for k in range(0, 10):
if tile != "":
break
iii = abs(i)
for l in range(0, 10):
name_minor = ew + norm(j, 3) + ns + norm(iii, 2)
if name_minor in state[name] and state[name][name_minor]["status"] == "done":
tile = name_minor
break
iii += ns_step
j += ew_step
jj += 1
ii += 1
if tile == "":
tile = "None"
c.send(tile.encode())
elif action == "status":
if name == "n-pole" or name == "s-pole":
c.send(state[name]["status"].encode())