From dc6e4848dd9d2e6ec2f8cc3850cdfab62e7a696d Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 20 Sep 2024 11:43:28 +0100 Subject: [PATCH] In prgress implementation for workflow manager - see #286 --- geest/core/workflow_job.py | 1 + geest/core/workflow_queue.py | 3 ++- geest/core/workflows/dont_use_workflow.py | 9 +++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/geest/core/workflow_job.py b/geest/core/workflow_job.py index f525c171..d2c6f769 100644 --- a/geest/core/workflow_job.py +++ b/geest/core/workflow_job.py @@ -1,4 +1,5 @@ from qgis.core import QgsTask, QgsMessageLog, QgsFeedback, Qgis +from PyQt5.QtCore import QObject, pyqtSignal from .workflow_factory import WorkflowFactory diff --git a/geest/core/workflow_queue.py b/geest/core/workflow_queue.py index 8a9a1f30..a1b92c29 100644 --- a/geest/core/workflow_queue.py +++ b/geest/core/workflow_queue.py @@ -1,3 +1,4 @@ +from functools import partial from qgis.core import QgsMessageLog, Qgis, QgsApplication from PyQt5.QtCore import QObject, pyqtSignal from typing import List, Optional @@ -102,7 +103,7 @@ def process_queue(self): partial(self.finalize_task, job_name=job.description()) ) - QgsApplication.taskManager().addTask(task) + QgsApplication.taskManager().addTask(job) self.update_status() diff --git a/geest/core/workflows/dont_use_workflow.py b/geest/core/workflows/dont_use_workflow.py index 22be9fbe..a3363203 100644 --- a/geest/core/workflows/dont_use_workflow.py +++ b/geest/core/workflows/dont_use_workflow.py @@ -1,3 +1,4 @@ +import time from qgis.core import QgsMessageLog, Qgis, QgsFeedback from .workflow_base import WorkflowBase @@ -22,15 +23,15 @@ def execute(self): steps = 10 for i in range(steps): - if self._feedback.isCanceled(): + if self.feedback.isCanceled(): QgsMessageLog.logMessage("Dont use workflow canceled.", 'Custom Workflows', Qgis.Warning) return False # Simulate progress and work - self._attributes['progress'] = f"Dont use workflow Step {i + 1} completed" - self._feedback.setProgress((i + 1) / steps * 100) # Report progress in percentage + self.attributes['progress'] = f"Dont use workflow Step {i + 1} completed" + self.feedback.setProgress((i + 1) / steps * 100) # Report progress in percentage time.sleep(1) # Simulate a task - self._attributes['result'] = 'Dont use workflow completed' + self.attributes['result'] = 'Dont use workflow completed' QgsMessageLog.logMessage("Dont use workflow workflow completed", 'Custom Workflows', Qgis.Info) return True