Refactor and fix

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2020-06-25 01:22:47 +10:00
parent 403dce4373
commit cfa151c8a1
2 changed files with 4 additions and 15 deletions

View file

@ -123,7 +123,7 @@ def get_job(action, host, port, none_exit=True):
msg = sock.recv(128)
sock.close()
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:
ret = match.group(0)
if ret == "None" and none_exit:

View file

@ -17,7 +17,6 @@
import socket
import sys
import json
import os
import re
import pymysql
@ -119,6 +118,7 @@ try:
action = "set"
name = match.group(2)
status = match.group(3)
set_state(name, status)
else:
match = re.match(r"(get) (started|rebuild|skip|pending|done)", msg)
if match != None:
@ -135,9 +135,6 @@ try:
else:
print("WARNING: Recived invalid package")
if action == "set":
set_state(name, status)
elif action == "get-job":
additional_type = ""
if get != "pending":
@ -171,21 +168,13 @@ try:
elif action == "status":
match = re.match(r"([ew])(\d{3})([ns])(\d{2})", name)
if match != None:
sql = "SELECT status_id FROM secondLevel WHERE name = '" + name + "'"
cursor.execute()
result = cursor.fetchone()
sql = "SELECT name FROM status WHERE id = " + result[0]
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM secondLevel WHERE name = '" + name + "')"
cursor.execute()
result = cursor.fetchone()
c.send(str(result[0]).encode())
else:
sql = "SELECT status_id FROM tile WHERE id = " + name
cursor.execute()
result = cursor.fetchone()
sql = "SELECT name FROM status WHERE id = " + result[0]
sql = "SELECT name FROM status WHERE id = (SELECT status_id FROM tile WHERE id = '" + name + "')"
cursor.execute()
result = cursor.fetchone()