Skip to content
Permalink
Browse files

[processing] Use silent feedback by default in processing.run

Relying on the iface messagebar feedback as a fallback is not
safe for standalone scripts. If callers want to use a message
bar feedback they should specify this feedback object specifically
when calling processing.run
  • Loading branch information
nyalldawson committed Apr 10, 2018
1 parent bf0c4f9 commit d5573a5a7bf5a32490b50f528da10c6f58871eab
Showing with 1 addition and 1 deletion.
  1. +1 −1 python/plugins/processing/core/Processing.py
@@ -116,7 +116,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
alg = QgsApplication.processingRegistry().createAlgorithmById(algOrName)

if feedback is None:
feedback = MessageBarProgress(alg.displayName() if alg else Processing.tr('Processing'))
feedback = QgsProcessingFeedback()

if alg is None:
# fix_print_with_import

1 comment on commit d5573a5

@MathieuChailloux

This comment has been minimized.

Copy link

@MathieuChailloux MathieuChailloux commented on d5573a5 Apr 17, 2018

Isn't the import missing ?

I've got name 'QgsProcessingFeedback' is not defined when my plugin calls r.cost through processing.run.
The error disappears when importing QgsProcessingFeedback.

Here is the full stacktrace

Traceback (most recent call last):
  File "C:/Users/mathieu.chailloux/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ecologicalcontinuity\eco_cont_dialog.py", line 83, in runCost
    raise e
  File "C:/Users/mathieu.chailloux/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ecologicalcontinuity\eco_cont_dialog.py", line 79, in runCost
    processing.run("grass7:r.cost",parameters)
  File "C:/TMP_OS\~1/apps/qgis-dev/./python/plugins\processing\tools\general.py", line 84, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:/TMP_OS\~1/apps/qgis-dev/./python/plugins\processing\core\Processing.py", line 119, in runAlgorithm
    feedback = QgsProcessingFeedback()
NameError: name 'QgsProcessingFeedback' is not defined

Best regards,
Mathieu

Please sign in to comment.
You can’t perform that action at this time.