mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Output useful logging when running algorithms from toolbox
Now outputs the input parameters, execution time, and results
This commit is contained in:
parent
1d6d4be556
commit
cb41ef1adc
@ -264,3 +264,14 @@ def fromFunction(description, function, *args, on_finished=None, flags=QgsTask.A
|
|||||||
|
|
||||||
|
|
||||||
QgsTask.fromFunction = fromFunction
|
QgsTask.fromFunction = fromFunction
|
||||||
|
|
||||||
|
|
||||||
|
# add some __repr__ methods to processing classes
|
||||||
|
def processing_source_repr(self):
|
||||||
|
return "<QgsProcessingFeatureSourceDefinition {{'source':{}, 'selectedFeaturesOnly': {}}}>".format(self.source.staticValue(), self.selectedFeaturesOnly)
|
||||||
|
QgsProcessingFeatureSourceDefinition.__repr__ = processing_source_repr
|
||||||
|
|
||||||
|
|
||||||
|
def processing_output_layer_repr(self):
|
||||||
|
return "<QgsProcessingOutputLayerDefinition {{'sink':{}, 'createOptions': {}}}>".format(self.sink.staticValue(), self.createOptions)
|
||||||
|
QgsProcessingOutputLayerDefinition.__repr__ = processing_output_layer_repr
|
||||||
|
@ -26,6 +26,9 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
|||||||
|
|
||||||
__revision__ = '$Format:%H$'
|
__revision__ = '$Format:%H$'
|
||||||
|
|
||||||
|
from pprint import pformat
|
||||||
|
import time
|
||||||
|
|
||||||
from qgis.PyQt.QtCore import Qt
|
from qgis.PyQt.QtCore import Qt
|
||||||
from qgis.PyQt.QtWidgets import QMessageBox, QApplication, QPushButton, QWidget, QVBoxLayout, QSizePolicy
|
from qgis.PyQt.QtWidgets import QMessageBox, QApplication, QPushButton, QWidget, QVBoxLayout, QSizePolicy
|
||||||
from qgis.PyQt.QtGui import QCursor, QColor, QPalette
|
from qgis.PyQt.QtGui import QCursor, QColor, QPalette
|
||||||
@ -168,8 +171,6 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
|||||||
|
|
||||||
parameters = self.getParamValues()
|
parameters = self.getParamValues()
|
||||||
|
|
||||||
QgsMessageLog.logMessage(str(parameters), 'Processing', QgsMessageLog.CRITICAL)
|
|
||||||
|
|
||||||
if checkCRS and not self.alg.validateInputCrs(parameters, context):
|
if checkCRS and not self.alg.validateInputCrs(parameters, context):
|
||||||
reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
|
reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
|
||||||
self.tr('Layers do not all use the same CRS. This can '
|
self.tr('Layers do not all use the same CRS. This can '
|
||||||
@ -221,6 +222,9 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
|||||||
self.setInfo(
|
self.setInfo(
|
||||||
self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.displayName()))
|
self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.displayName()))
|
||||||
|
|
||||||
|
feedback.pushInfo(self.tr('Input parameters:\n{}\n'.format(pformat(parameters))))
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
if self.iterateParam:
|
if self.iterateParam:
|
||||||
if executeIterating(self.alg, parameters, self.iterateParam, context, feedback):
|
if executeIterating(self.alg, parameters, self.iterateParam, context, feedback):
|
||||||
self.finish(parameters, context, feedback)
|
self.finish(parameters, context, feedback)
|
||||||
@ -234,6 +238,9 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
|||||||
# ProcessingLog.addToLog(command)
|
# ProcessingLog.addToLog(command)
|
||||||
self.buttonCancel.setEnabled(self.alg.flags() & QgsProcessingAlgorithm.FlagCanCancel)
|
self.buttonCancel.setEnabled(self.alg.flags() & QgsProcessingAlgorithm.FlagCanCancel)
|
||||||
result = executeAlgorithm(self.alg, parameters, context, feedback)
|
result = executeAlgorithm(self.alg, parameters, context, feedback)
|
||||||
|
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
||||||
|
feedback.pushInfo(self.tr('Results:\n{}\n'.format(pformat(result))))
|
||||||
|
|
||||||
self.buttonCancel.setEnabled(False)
|
self.buttonCancel.setEnabled(False)
|
||||||
self.finish(result, context, feedback)
|
self.finish(result, context, feedback)
|
||||||
#TODO
|
#TODO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user