Skip to content

Commit

Permalink
In prgress implementation for workflow manager - see #286
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux committed Sep 20, 2024
1 parent 8e1b8f7 commit dc6e484
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions geest/core/workflow_job.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from qgis.core import QgsTask, QgsMessageLog, QgsFeedback, Qgis
from PyQt5.QtCore import QObject, pyqtSignal
from .workflow_factory import WorkflowFactory


Expand Down
3 changes: 2 additions & 1 deletion geest/core/workflow_queue.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

Expand Down
9 changes: 5 additions & 4 deletions geest/core/workflows/dont_use_workflow.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from qgis.core import QgsMessageLog, Qgis, QgsFeedback
from .workflow_base import WorkflowBase

Expand All @@ -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

0 comments on commit dc6e484

Please sign in to comment.