diff --git a/{{cookiecutter.profile_name}}/lsf_status.py b/{{cookiecutter.profile_name}}/lsf_status.py index 5589f44..6095c88 100755 --- a/{{cookiecutter.profile_name}}/lsf_status.py +++ b/{{cookiecutter.profile_name}}/lsf_status.py @@ -27,6 +27,17 @@ class UnknownStatusLine(Exception): ZOMBIE = "ZOMBI" +def extract_job_status(bjobs_output): + import re + + response = bjobs_output.split('\n') + if len(response) != 2: + return "UNKNOWN" + + response = response[1] + return re.split("[\\t\\r\\n ]+", response)[2] + + class StatusChecker: SUCCESS = "success" RUNNING = "running" @@ -70,7 +81,7 @@ def outlog(self) -> str: @property def bjobs_query_cmd(self) -> str: - return "bjobs -o 'stat' -noheader {jobid}".format(jobid=self.jobid) + return "bjobs {jobid}".format(jobid=self.jobid) def _handle_unknown_job(self) -> str: if self.kill_unknown: @@ -105,6 +116,8 @@ def _query_status_using_bjobs(self) -> str: ) ) + output_stream = extract_job_status(output_stream) + if output_stream == UNKNOWN: return self._handle_unknown_job()