Skip to content
Snippets Groups Projects
Commit 7f289b43 authored by Gioacchino Vino's avatar Gioacchino Vino
Browse files

Reviewed code

parent 3db15529
No related branches found
No related tags found
1 merge request!143Debug paas ci
...@@ -284,6 +284,9 @@ class Task: ...@@ -284,6 +284,9 @@ class Task:
get_report_info = retrieves report information get_report_info = retrieves report information
""" """
# Constants
WAIT_SECONDS = 10
def __init__(self, def __init__(self,
client, client,
name: str, name: str,
...@@ -392,12 +395,12 @@ class Task: ...@@ -392,12 +395,12 @@ class Task:
def delete(self): def delete(self):
res = self.client.delete_task(self.id) res = self.client.delete_task(self.id)
status = res.xpath(GVM_XPATH_STATUS)[0] #status = res.xpath(GVM_XPATH_STATUS)[0]
status_text = res.xpath(GVM_XPATH_STATUS_TEXT)[0] #status_text = res.xpath(GVM_XPATH_STATUS_TEXT)[0]
if status == GVM_STATUS_OK: #if status == GVM_STATUS_OK:
logging.info(f"Task {self} DELETED") # logging.info(f"Task {self} DELETED")
else: #else:
logging.error(f"ERROR during the task deletion {status}: {status_text}") # logging.error(f"ERROR during the task deletion {status}: {status_text}")
def __del__(self): def __del__(self):
self.delete() self.delete()
...@@ -413,13 +416,13 @@ class Task: ...@@ -413,13 +416,13 @@ class Task:
self.report_id = task_info.xpath(GVM_XPATH_LAST_REPORT_ID)[0] self.report_id = task_info.xpath(GVM_XPATH_LAST_REPORT_ID)[0]
except Exception: except Exception:
pass pass
d = { """d = {
"name": self.name, "name": self.name,
"status": self.status, "status": self.status,
"progress":self.progress, "progress":self.progress,
"in_use":self.in_use, "in_use":self.in_use,
} }
logging.debug(f"update_status: \n {pretty_json(d)}") logging.debug(f"update_status: \n {pretty_json(d)}")"""
def wait(self, timeout: int = 7200) -> bool: def wait(self, timeout: int = 7200) -> bool:
start_time = time() start_time = time()
...@@ -436,7 +439,7 @@ class Task: ...@@ -436,7 +439,7 @@ class Task:
logging.error("TIMEOUT during waiting for task ending") logging.error("TIMEOUT during waiting for task ending")
return False return False
logging.debug(f"Waiting for the task ends. Now {int(time() - start_time)}s from start. Status: {self.status}") logging.debug(f"Waiting for the task ends. Now {int(time() - start_time)}s from start. Status: {self.status}")
sleep(10) sleep(self.WAIT_SECONDS)
def save_report(self, format: str, filename: str): def save_report(self, format: str, filename: str):
res = self.client.get_report(self.report_id, res = self.client.get_report(self.report_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment