Fixed not sending the status

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2021-03-04 14:21:32 +00:00
parent 3fd2c90929
commit a4d0126a14

View file

@ -116,18 +116,18 @@ def send_status(name, status, host, port):
sys.exit(1) sys.exit(1)
# Sends status to the manager api # Sends status to the manager api
def api_send_status(name, status, api, api_token): def api_send_status(name, status, api, token):
try: try:
success = False success = False
while not success: while not success:
response = requests.post(api, data={'auth': token, 'action': 'set', 'tile': name}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"}) response = requests.post(api, data={'auth': token, 'action': 'set', 'tile': name, 'status': status}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"})
success = response.json()["success"] success = response.json()["success"]
if not success: if not success:
print("Warning: Unable to send status " + status + " for tile " + name + ". Trying again in 60 seconds") print("Warning: Unable to send status " + status + " for tile " + name + ". Trying again in 60 seconds")
sleep(60) sleep(60)
except IOError: except IOError:
print("Unable to send status " + status + " for tile " + name + ". Aborting...") print("Warning: Unable to send status " + status + " for tile " + name + ". Trying again in 60 seconds")
sys.exit(1) sleep(60)
# Gets new job from manager # Gets new job from manager
def get_job(action, host, port, none_exit=True): def get_job(action, host, port, none_exit=True):
@ -159,7 +159,7 @@ def get_job(action, host, port, none_exit=True):
def api_get_job(action, api, token, none_exit=True): def api_get_job(action, api, token, none_exit=True):
try: try:
response = requests.post(api, data={'auth': token, 'action': 'get-job', 'additional-type': action}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"}) response = requests.post(api, data={'auth': token, 'action': 'get-job', 'additional-type': action}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"})
match = re.match(r"[ew]\d{3}[ns]\d{2}|[0-9]{1,7}|None", responce.json()["job"]) match = re.match(r"[ew]\d{3}[ns]\d{2}|[0-9]{1,7}|None", str(response.json()["job"]))
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: