From e0bf908b25929837765b1ddf22a4799abea7d143 Mon Sep 17 00:00:00 2001 From: fly Date: Mon, 15 May 2023 19:00:31 +0000 Subject: [PATCH] Fix referenced before assignment issue Signed-off-by: fly --- common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common.py b/common.py index 3be89d9..1c8a39c 100644 --- a/common.py +++ b/common.py @@ -170,6 +170,7 @@ def get_job(action, host, port, none_exit=True): # Gets new job from manager api def api_get_job(action, new_status, api, token, level, none_exit=True, all_in_parent=0): + response = None try: response = requests.post(api, data={'auth': token, 'action': 'get-job', 'status': action, 'new-status': new_status, "all-in-parent": all_in_parent, "level": level}, headers={"lAccept": "application/json", "Content-Type": "application/x-www-form-urlencoded"}) if response.ok and response.json()["success"] == True: @@ -184,7 +185,8 @@ def api_get_job(action, new_status, api, token, level, none_exit=True, all_in_pa else: return None except (ConnectionError, OSError, IOError, json.JSONDecodeError): - print(response.text) + if response != None: + print(response.text) return None # Gets status of a tile