diff --git a/pyccc/job.py b/pyccc/job.py index c4c109d..d3dd30e 100644 --- a/pyccc/job.py +++ b/pyccc/job.py @@ -100,6 +100,7 @@ def __init__(self, engine=None, self._callback_result = None self._output_files = None self.jobid = None + self._stopped = None if submit and self.engine and self.image: self.submit() @@ -140,11 +141,17 @@ def status(self): """ Returns status of 'queued', 'running', 'finished' or 'error' """ - if self.jobid: - return self.engine.get_status(self) + if self._stopped: + return self._stopped + elif self.jobid: + stat = self.engine.get_status(self) + if stat in status.DONE_STATES: + self._stopped = stat + return stat else: return "Unsubmitted" + def _finish_job(self): """ To be called after job has finished. @@ -152,11 +159,12 @@ def _finish_job(self): :return: """ if self._finished: return - if self.status not in status.DONE_STATES: + stat = self.status + if stat not in status.DONE_STATES: raise pyccc.JobStillRunning(self) - if self.status != status.FINISHED: - raise pyccc.JobErrorState(self, 'Job did not complete successfully (status:%s)' % - self.status) + if stat != status.FINISHED: + raise pyccc.JobErrorState(self, 'Job did not complete successfully (status:%s)'% + stat) self._output_files = self.engine._list_output_files(self) self._final_stdout, self._final_stderr = self.engine._get_final_stds(self) self._finished = True diff --git a/pyccc/ui.py b/pyccc/ui.py index f8b284e..338941e 100644 --- a/pyccc/ui.py +++ b/pyccc/ui.py @@ -188,17 +188,18 @@ def __init__(self, job, **kwargs): super(StatusView,self).__init__(**kwargs) self._job = job - text = ipy.HTML(self.STATUS_STRING % (job.name, + stat = job.status + text = ipy.HTML(self.STATUS_STRING%(job.name, str(job.engine), job.jobid, job.image, job.command, - job.status)) - if job.status == status.QUEUED: + stat)) + if stat == status.QUEUED: bar_spec = dict(value=1, bar_style='danger') - elif job.status == status.RUNNING: + elif stat == status.RUNNING: bar_spec = dict(value=50, bar_style='info') - elif job.status == status.FINISHED: + elif stat == status.FINISHED: bar_spec = dict(value=100, bar_style='success') else: bar_spec = dict(value=100, bar_style='danger')