def state(self): """ Returns the state of the pipeline """ path = os.path.join(self.config("dirs.pipeline_runtime"), str(self.pid), "pipeline.xml") for line in open(path): if "<state>" in line: return getStrBetween(line, "<state>", "</state>") raise PipelineError("Could not find <state> in the pipeline.xml")
def _pipelineState(workflowXML): if not os.path.exists(workflowXML): return tasks_tx.task.TASK_FAILED for _ in range(10): for line in open(workflowXML): if '<state>' in line: state = core.getStrBetween(line, '<state>', '</state>') if state in ['failed', 'error']: return tasks_tx.task.TASK_FAILED elif state == 'running': return tasks_tx.task.TASK_RUNNING elif state == 'complete': return tasks_tx.task.TASK_COMPLETED else: return tasks_tx.task.TASK_IDLE time.sleep(1) raise Error('Could not find state')