Refactor and fix
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
403dce4373
commit
cfa151c8a1
2 changed files with 4 additions and 15 deletions
|
@ -123,7 +123,7 @@ def get_job(action, host, port, none_exit=True):
|
||||||
msg = sock.recv(128)
|
msg = sock.recv(128)
|
||||||
sock.close()
|
sock.close()
|
||||||
msg = msg.decode()
|
msg = msg.decode()
|
||||||
match = re.match(r"n-pole|s-pole|[ew]\d{3}[ns]\d{2}|None", msg)
|
match = re.match(r"[ew]\d{3}[ns]\d{2}|[0-9]{1,7}|None", msg)
|
||||||
if match != None:
|
if match != None:
|
||||||
ret = match.group(0)
|
ret = match.group(0)
|
||||||
if ret == "None" and none_exit:
|
if ret == "None" and none_exit:
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pymysql
|
import pymysql
|
||||||
|
@ -119,6 +118,7 @@ try:
|
||||||
action = "set"
|
action = "set"
|
||||||
name = match.group(2)
|
name = match.group(2)
|
||||||
status = match.group(3)
|
status = match.group(3)
|
||||||
|
set_state(name, status)
|
||||||
else:
|
else:
|
||||||
match = re.match(r"(get) (started|rebuild|skip|pending|done)", msg)
|
match = re.match(r"(get) (started|rebuild|skip|pending|done)", msg)
|
||||||
if match != None:
|
if match != None:
|
||||||
|
@ -135,9 +135,6 @@ try:
|
||||||
else:
|
else:
|
||||||
print("WARNING: Recived invalid package")
|
print("WARNING: Recived invalid package")
|
||||||
|
|
||||||
if action == "set":
|
|
||||||
set_state(name, status)
|
|
||||||
|
|
||||||
elif action == "get-job":
|
elif action == "get-job":
|
||||||
additional_type = ""
|
additional_type = ""
|
||||||
if get != "pending":
|
if get != "pending":
|
||||||
|
@ -171,21 +168,13 @@ try:
|
||||||
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 status_id FROM secondLevel WHERE name = '" + name + "'"
|
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM secondLevel WHERE name = '" + name + "')"
|
||||||
cursor.execute()
|
|
||||||
result = cursor.fetchone()
|
|
||||||
|
|
||||||
sql = "SELECT name FROM status WHERE id = " + result[0]
|
|
||||||
cursor.execute()
|
cursor.execute()
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|
||||||
c.send(str(result[0]).encode())
|
c.send(str(result[0]).encode())
|
||||||
else:
|
else:
|
||||||
sql = "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()
|
|
||||||
result = cursor.fetchone()
|
|
||||||
|
|
||||||
sql = "SELECT name FROM status WHERE id = " + result[0]
|
|
||||||
cursor.execute()
|
cursor.execute()
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue