Fixed exceptions

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2021-03-12 17:23:45 +00:00
parent be0d609bda
commit 20da6220a2

View file

@ -117,9 +117,9 @@ def send_status(name, status, host, port):
# Sends status to the manager api
def api_send_status(name, status, api, token):
try:
success = False
while not success:
success = False
while not success:
try:
response = requests.post(api, data={'auth': token, 'action': 'set', 'tile': name, 'status': status}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"})
if response.ok:
success = response.json()["success"]
@ -129,9 +129,9 @@ def api_send_status(name, status, api, token):
else:
print("Warning: Unable to send status '" + status + "' for tile '" + name + "'. Trying again in 60 seconds")
sleep(60)
except IOError:
print("Warning: Unable to send status " + status + " for tile " + name + ". Trying again in 60 seconds")
sleep(60)
except ConnectionError:
print("Warning: Unable to send status " + status + " for tile " + name + ". Trying again in 60 seconds")
sleep(60)
# Gets new job from manager
def get_job(action, host, port, none_exit=True):
@ -179,10 +179,10 @@ def api_get_job(action, api, token, none_exit=True):
print("Unable to get job. Retrying in 60 seconds...")
sleep(60)
ret = api_get_job(action, api, token, none_exit)
except IOError:
except ConnectionError:
print("Unable to get job. Retrying in 60 seconds...")
sleep(60)
ret = get_job(action, host, port, none_exit)
ret = api_get_job(action, api, token, none_exit)
return ret
# Gets status of a tile
@ -222,6 +222,6 @@ def api_get_status(name, api, api_token):
else:
print("ERROR: Unable to get status.")
sys.exit(1)
except IOError:
except ConnectionError:
print("ERROR: Unable to get status.")
sys.exit(1)