From 9c4354a3e822779c9efd9a405dfb7bc1992585a8 Mon Sep 17 00:00:00 2001 From: fly Date: Wed, 17 Mar 2021 12:24:56 +0000 Subject: [PATCH] Check for successful status Signed-off-by: fly --- common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common.py b/common.py index 7012011..9e64092 100644 --- a/common.py +++ b/common.py @@ -163,7 +163,7 @@ def get_job(action, host, port, none_exit=True): def api_get_job(action, api, token, none_exit=True): 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"}) - 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"])) if match != None: 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"}) else: 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"]) if match != None: return match.group(0)