From d2cfbc2ba2ecc2e9a2b5b07e4ed27c7c440af6b1 Mon Sep 17 00:00:00 2001 From: Harry Saunders <harry.saunders@tessella.com> Date: Thu, 24 Jan 2019 15:03:30 +0000 Subject: [PATCH] Add script execution timestamp to editor status AsyncTaskResult objects store timestamp as string during construction. This stamp is displayed in the editor status window whenever a script is run. Refs #24479 --- qt/python/mantidqt/utils/asynchronous.py | 1 + .../mantidqt/widgets/codeeditor/interpreter.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/qt/python/mantidqt/utils/asynchronous.py b/qt/python/mantidqt/utils/asynchronous.py index 8ad6c59d018..5d104be19e8 100644 --- a/qt/python/mantidqt/utils/asynchronous.py +++ b/qt/python/mantidqt/utils/asynchronous.py @@ -110,6 +110,7 @@ class AsyncTaskResult(object): def __init__(self, elapsed_time): self.elapsed_time = elapsed_time + self.timestamp = time.ctime() class AsyncTaskSuccess(AsyncTaskResult): diff --git a/qt/python/mantidqt/widgets/codeeditor/interpreter.py b/qt/python/mantidqt/widgets/codeeditor/interpreter.py index d1bdb6a8db9..67c7b229c20 100644 --- a/qt/python/mantidqt/widgets/codeeditor/interpreter.py +++ b/qt/python/mantidqt/widgets/codeeditor/interpreter.py @@ -27,7 +27,7 @@ from mantidqt.io import open_a_file_dialog # Status messages IDLE_STATUS_MSG = "Status: Idle." -LAST_JOB_MSG_TEMPLATE = "Last job completed {} in {:.3f}s" +LAST_JOB_MSG_TEMPLATE = "Last job completed {} at {} in {:.3f}s" RUNNING_STATUS_MSG = "Status: Running" # Editor @@ -237,7 +237,7 @@ class PythonFileInterpreterPresenter(QObject): def _on_exec_success(self, task_result): self.view.editor.updateCompletionAPI(self.model.generate_calltips()) - self._finish(success=True, elapsed_time=task_result.elapsed_time) + self._finish(success=True, task_result=task_result) def _on_exec_error(self, task_error): exc_type, exc_value, exc_stack = task_error.exc_type, task_error.exc_value, \ @@ -251,19 +251,19 @@ class PythonFileInterpreterPresenter(QObject): lineno = -1 sys.stderr.write(self._error_formatter.format(exc_type, exc_value, exc_stack) + os.linesep) self.view.editor.updateProgressMarker(lineno, True) - self._finish(success=False, elapsed_time=task_error.elapsed_time) + self._finish(success=False, task_result=task_error) - def _finish(self, success, elapsed_time): + def _finish(self, success, task_result): status = 'successfully' if success else 'with errors' - self.view.set_status_message(self._create_status_msg(status, - elapsed_time)) + status_message = self._create_status_msg(status, task_result.timestamp, + task_result.elapsed_time) + self.view.set_status_message(status_message) self.view.set_editor_readonly(False) self.is_executing = False - def _create_status_msg(self, status, elapsed_time): + def _create_status_msg(self, status, timestamp, elapsed_time): return IDLE_STATUS_MSG + ' ' + \ - LAST_JOB_MSG_TEMPLATE.format(status, - elapsed_time) + LAST_JOB_MSG_TEMPLATE.format(status, timestamp, elapsed_time) def _on_progress_update(self, lineno): """Update progress on the view taking into account if a selection of code is -- GitLab