Bug fixes and change execution order
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
8d846dc491
commit
5e645299cd
1 changed files with 12 additions and 10 deletions
|
@ -97,7 +97,7 @@ def set_state(name, status):
|
||||||
sql = "UPDATE tile SET status_id = " + str(sid[0]) + " WHERE parent_id = " + str(pid[0])
|
sql = "UPDATE tile SET status_id = " + str(sid[0]) + " WHERE parent_id = " + str(pid[0])
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
else:
|
else:
|
||||||
sql = "UPDATE tile SET status_id = (SELECT if FROM status WHERE name = '" + status + "') WHERE id = " + name
|
sql = "UPDATE tile SET status_id = (SELECT id FROM status WHERE name = '" + status + "') WHERE id = " + name
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
@ -113,6 +113,8 @@ try:
|
||||||
msg = c.recv(128)
|
msg = c.recv(128)
|
||||||
msg = msg.decode()
|
msg = msg.decode()
|
||||||
|
|
||||||
|
db.ping(reconnect=True)
|
||||||
|
|
||||||
match = re.match(r"(set) ([ew]\d{3}[ns]\d{2}|[0-9]{1,7}) (done|started|rebuild|skip|pending|packaged)", msg)
|
match = re.match(r"(set) ([ew]\d{3}[ns]\d{2}|[0-9]{1,7}) (done|started|rebuild|skip|pending|packaged)", msg)
|
||||||
if match != None:
|
if match != None:
|
||||||
action = "set"
|
action = "set"
|
||||||
|
@ -139,22 +141,22 @@ try:
|
||||||
additional_type = ""
|
additional_type = ""
|
||||||
if get != "pending":
|
if get != "pending":
|
||||||
additional_type = "OR status_id = (SELECT id FROM status WHERE name = '" + get + "')"
|
additional_type = "OR status_id = (SELECT id FROM status WHERE name = '" + get + "')"
|
||||||
sql = "SELECT id FROM tile WHERE status_id = (SELECT id FROM status WHERE name = 'pending') " + additional_type + " LIMIT 1"
|
sql = "SELECT id FROM tile WHERE status_id = (SELECT id FROM status WHERE name = 'pending') " + additional_type + " ORDER BY parent_id LIMIT 1"
|
||||||
cursor.execute()
|
cursor.execute(sql)
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
if result == None:
|
if result == None:
|
||||||
tile = "None"
|
tile = "None"
|
||||||
else:
|
else:
|
||||||
tile = result[0]
|
tile = result[0]
|
||||||
sql = "UPDATE tile SET status_id = (SELECT id FROM status WHERE name = 'started') WHERE id = " + tile
|
sql = "UPDATE tile SET status_id = (SELECT id FROM status WHERE name = 'started') WHERE id = " + str(tile)
|
||||||
cursor.execute()
|
cursor.execute(sql)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Asigning job on tile " + tile)
|
print("Asigning job on tile " + str(tile))
|
||||||
|
|
||||||
c.send(tile.encode())
|
c.send(str(tile).encode())
|
||||||
elif action == "get-done":
|
elif action == "get-done":
|
||||||
sql = "SELECT id FROM secondLevel WHERE status_id = (SELECT id FROM status WHERE name = 'done') LIMIT 1"
|
sql = "SELECT id FROM secondLevel WHERE status_id = (SELECT id FROM status WHERE name = 'done') LIMIT 1"
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
@ -164,18 +166,18 @@ try:
|
||||||
else:
|
else:
|
||||||
tile = result[0]
|
tile = result[0]
|
||||||
|
|
||||||
c.send(tile.encode())
|
c.send(str(tile).encode())
|
||||||
elif action == "status":
|
elif action == "status":
|
||||||
match = re.match(r"([ew])(\d{3})([ns])(\d{2})", name)
|
match = re.match(r"([ew])(\d{3})([ns])(\d{2})", name)
|
||||||
if match != None:
|
if match != None:
|
||||||
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM secondLevel WHERE name = '" + name + "')"
|
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM secondLevel WHERE name = '" + name + "')"
|
||||||
cursor.execute()
|
cursor.execute(sql)
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|
||||||
c.send(str(result[0]).encode())
|
c.send(str(result[0]).encode())
|
||||||
else:
|
else:
|
||||||
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM tile WHERE id = '" + name + "')"
|
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM tile WHERE id = '" + name + "')"
|
||||||
cursor.execute()
|
cursor.execute(sql)
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|
||||||
c.send(str(result[0]).encode())
|
c.send(str(result[0]).encode())
|
||||||
|
|
Loading…
Reference in a new issue