Check for successful status

Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
fly 2021-03-17 12:24:56 +00:00
parent 1b12dfc508
commit 9c4354a3e8

View file

@ -163,7 +163,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"})
if response.ok: if response.ok and response.json()["success"] == True:
match = re.match(r"[ew]\d{3}[ns]\d{2}|[0-9]{1,7}|None", str(response.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)
@ -213,7 +213,7 @@ def api_get_status(name, api, api_token):
response = requests.post(api, data={'auth': token, 'action': 'status', 'area': name}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"}) response = requests.post(api, data={'auth': token, 'action': 'status', 'area': name}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"})
else: else:
response = requests.post(api, data={'auth': token, 'action': 'status', 'tile': name}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"}) response = requests.post(api, data={'auth': token, 'action': 'status', 'tile': name}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"})
if response.ok: if response.ok and response.json()["success"] == True:
match = re.match(r"pending|done|rebuild|skip|started|packaged", response.json()["status"]) match = re.match(r"pending|done|rebuild|skip|started|packaged", response.json()["status"])
if match != None: if match != None:
return match.group(0) return match.group(0)