Commit a176dc05 authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

Manage wf postprocess status.

parent a6c2b748
......@@ -94,6 +94,7 @@ class Workflow(threading.Thread):
OLD_EXTENSION = ".old"
DEFAULT_GROUP = "default"
STATUS_PENDING = "pending"
STATUS_STARTED = "started"
STATUS_COMPLETED = "completed"
STATUS_FAILED = "failed"
......@@ -117,6 +118,7 @@ class Workflow(threading.Thread):
self.globals = {}
self.options = Options()
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self.start_time = None
self.end_time = None
self.__step = None
......@@ -507,8 +509,8 @@ class Workflow(threading.Thread):
else: completed = "completed:" + str(status_info["completed"])
if display_errors and len(status_info["failed_commands"]) > 0:
if components_errors == "" :
components_errors = "Failed Commands :\n"
if components_errors == "":
components_errors = "Failed Commands :\n"
components_errors += " - " + component + " :\n " + "\n ".join(status_info["failed_commands"]) + "\n"
status += " - " + component + ", time elapsed " + time_format(status_info["time"]) + \
" (total:" + str(status_info["tasks"]) + ", " + waiting + ", " + running + ", " + failed + \
......@@ -820,6 +822,7 @@ class Workflow(threading.Thread):
self.start_time = time.time()
self.__step = 0
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self.end_time = None
# if some args are provided, let's fill the parameters
self._set_parameters(self.args)
......@@ -835,6 +838,7 @@ class Workflow(threading.Thread):
self.reseted_components = []
self.components = []
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self.wf_execution_wrapper()
except SystemExit:
self.status = self.STATUS_FAILED
......@@ -855,6 +859,7 @@ class Workflow(threading.Thread):
self.reseted_components = []
self.components = []
self.status = self.STATUS_STARTED
self.postprocess_status = self.STATUS_PENDING
self.wf_execution_wrapper()
except SystemExit:
self.status = self.STATUS_FAILED
......@@ -868,11 +873,19 @@ class Workflow(threading.Thread):
self._serialize()
# if post processing has ne been done yet
if self.__step == 3:
self.post_process()
if self.status == self.STATUS_STARTED: self.status = self.STATUS_COMPLETED
self.end_time = time.time()
self._serialize()
self._send_email()
try:
self.postprocess_status = self.STATUS_STARTED
self.post_process()
self.postprocess_status = self.STATUS_COMPLETED
self.status = self.STATUS_COMPLETED
except:
self.postprocess_status = self.STATUS_FAILED
raise
finally:
self.end_time = time.time()
self._serialize()
self._send_email()
except Exception as e:
self._log(str(e), traceback=traceback.format_exc(chain=False))
utils.display_error_message(str(e))
......@@ -894,6 +907,8 @@ class Workflow(threading.Thread):
self.status = self.STATUS_ABORTED
elif self.STATUS_FAILED in make_states:
self.status = self.STATUS_FAILED
elif self.postprocess_status == self.STATUS_FAILED:
self.status = self.STATUS_FAILED
elif self.status != self.STATUS_COMPLETED:
self.status = self.STATUS_STARTED
except: pass
......@@ -918,7 +933,7 @@ class Workflow(threading.Thread):
"tasks": 0,
"waiting": 0,
"running": 0,
"failed":0,
"failed": 0,
"aborted": 0,
"completed": 0,
"failed_commands": list() }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment