Skip to content
Permalink
Browse files
Just use standard QgsMessageLog functionality instead of a dedicated
method for processing
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 93c32e6 commit e9f13d1ea30571a71a0dd9bea45d5368e23e0ac4
Showing with 141 additions and 185 deletions.
  1. +1 −1 doc/api_break.dox
  2. +0 −5 python/core/processing/qgsprocessingutils.sip
  3. +2 −2 python/plugins/processing/algs/gdal/GdalUtils.py
  4. +2 −2 python/plugins/processing/algs/grass7/Grass7Algorithm.py
  5. +3 −6 python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py
  6. +1 −1 python/plugins/processing/algs/grass7/Grass7Utils.py
  7. +1 −2 python/plugins/processing/algs/qgis/Centroids.py
  8. +3 −4 python/plugins/processing/algs/qgis/Clip.py
  9. +1 −2 python/plugins/processing/algs/qgis/Difference.py
  10. +10 −12 python/plugins/processing/algs/qgis/Dissolve.py
  11. +2 −2 python/plugins/processing/algs/qgis/EliminateSelection.py
  12. +1 −2 python/plugins/processing/algs/qgis/FixGeometry.py
  13. +4 −8 python/plugins/processing/algs/qgis/Gridify.py
  14. +1 −2 python/plugins/processing/algs/qgis/Heatmap.py
  15. +4 −6 python/plugins/processing/algs/qgis/Intersection.py
  16. +2 −3 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  17. +2 −3 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  18. +2 −3 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  19. +2 −3 python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
  20. +2 −3 python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py
  21. +24 −24 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsVariable.py
  22. +1 −1 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  23. +1 −1 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  24. +2 −2 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  25. +2 −2 python/plugins/processing/algs/qgis/SplitLinesWithLines.py
  26. +1 −2 python/plugins/processing/algs/qgis/SplitWithLines.py
  27. +4 −4 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  28. +16 −16 python/plugins/processing/algs/qgis/Union.py
  29. +1 −1 python/plugins/processing/algs/qgis/ui/FieldsCalculatorDialog.py
  30. +1 −1 python/plugins/processing/algs/r/RAlgorithm.py
  31. +4 −4 python/plugins/processing/algs/r/RAlgorithmProvider.py
  32. +1 −1 python/plugins/processing/algs/r/RUtils.py
  33. +1 −1 python/plugins/processing/algs/saga/SagaAlgorithm.py
  34. +9 −8 python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
  35. +2 −3 python/plugins/processing/algs/saga/SagaUtils.py
  36. +3 −4 python/plugins/processing/core/GeoAlgorithm.py
  37. +4 −10 python/plugins/processing/core/Processing.py
  38. +1 −1 python/plugins/processing/gui/AlgorithmExecutor.py
  39. +1 −2 python/plugins/processing/gui/HelpEditionDialog.py
  40. +1 −2 python/plugins/processing/gui/Postprocessing.py
  41. +4 −4 python/plugins/processing/modeler/ModelerAlgorithmProvider.py
  42. +5 −4 python/plugins/processing/modeler/ModelerDialog.py
  43. +1 −1 python/plugins/processing/script/ScriptAlgorithm.py
  44. +5 −4 python/plugins/processing/script/ScriptUtils.py
  45. +0 −5 src/core/processing/qgsprocessingutils.cpp
  46. +0 −5 src/core/processing/qgsprocessingutils.h
@@ -2229,7 +2229,7 @@ object of type QgsProcessingFeedback, and will need to adapt their use of progre
- SilentProgress was removed. Use the base QgsProcessingFeedback class instead.
- algList was removed. Use QgsApplication.processingRegistry() instead.
- Processing.algs was removed. QgsApplication.processingRegistry().algorithms() instead.
- ProcessingLog should not be used when reporting log messages from algorithms. Use QgsProcessingUtils.logMessage() instead.
- ProcessingLog should not be used when reporting log messages from algorithms. Use QgsMessageLog.logMessage() instead.

Triangulation {#qgis_api_break_3_0_Triangulation}
-------------
@@ -124,11 +124,6 @@ class QgsProcessingUtils
:rtype: list of QVariant
%End

static void logMessage( QgsMessageLog::MessageLevel level, const QString &message );
%Docstring
Logs a processing ``message`` of a specified ``level`` to the QGIS message log.
%End

};


@@ -80,7 +80,7 @@ def runGdal(commands, feedback=None):
os.putenv('PATH', envval)

fused_command = ' '.join([str(c) for c in commands])
QgsProcessingUtils.logMessage(QgsMessageLog.INFO, fused_command)
QgsMessageLog.logMessage(fused_command, 'Processing', QgsMessageLog.INFO)
feedback.pushInfo('GDAL command:')
feedback.pushCommandInfo(fused_command)
feedback.pushInfo('GDAL command output:')
@@ -108,7 +108,7 @@ def runGdal(commands, feedback=None):
else:
raise IOError(e.message + u'\nTried 5 times without success. Last iteration stopped after reading {} line(s).\nLast line(s):\n{}'.format(len(loglines), u'\n'.join(loglines[-10:])))

QgsProcessingUtils.logMessage(QgsMessageLog.INFO, '\n'.join(loglines))
QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', QgsMessageLog.INFO)
GdalUtils.consoleOutput = loglines

@staticmethod
@@ -189,7 +189,7 @@ def defineCharacteristicsFromFile(self):
"txt"))
line = lines.readline().strip('\n').strip()
except Exception as e:
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL, self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(self.descriptionFile, line))
QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(self.descriptionFile, line), self.tr('Processing'), QgsMessageLog.CRITICAL)
raise e

self.addParameter(ParameterExtent(
@@ -299,7 +299,7 @@ def processAlgorithm(self, context, feedback):
feedback.pushCommandInfo(line)
loglines.append(line)
if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_COMMANDS):
QgsProcessingUtils.logMessage(QgsMessageLog.INFO, loglines)
QgsMessageLog.logMessage(loglines, self.tr('Processing'), QgsMessageLog.INFO)

Grass7Utils.executeGrass7(self.commands, feedback, self.outputCommands)

@@ -98,13 +98,10 @@ def createAlgsList(self):
if alg.name().strip() != '':
algs.append(alg)
else:
QgsProcessingUtils.logMessage(
QgsMessageLog.CRITICAL,
self.tr('Could not open GRASS GIS 7 algorithm: {0}').format(descriptionFile))
QgsMessageLog.logMessage(self.tr('Could not open GRASS GIS 7 algorithm: {0}').format(descriptionFile), self.tr('Processing'), QgsMessageLog.CRITICAL)
except Exception as e:
QgsProcessingUtils.logMessage(
QgsMessageLog.CRITICAL,
self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(descriptionFile, str(e)))
QgsMessageLog.logMessage(
self.tr('Could not open GRASS GIS 7 algorithm: {0}\n{1}').format(descriptionFile, str(e)), self.tr('Processing'), QgsMessageLog.CRITICAL)
algs.append(nviz7())
return algs

@@ -335,7 +335,7 @@ def executeGrass7(commands, feedback, outputCommands=None):
feedback.pushConsoleInfo(line)

if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_CONSOLE):
QgsProcessingUtils.logMessage(QgsMessageLog.INFO, loglines)
QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', QgsMessageLog.INFO)

# GRASS session is used to hold the layers already exported or
# produced in GRASS between multiple calls to GRASS algorithms.
@@ -81,8 +81,7 @@ def processAlgorithm(self, context, feedback):
if input_feature.geometry():
output_geometry = input_feature.geometry().centroid()
if not output_geometry:
QgsProcessingUtils.logMessage(QgsMessageLog.WARNING,
'Error calculating centroid for feature {}'.format(input_feature.id()))
QgsMessageLog.logMessage('Error calculating centroid for feature {}'.format(input_feature.id()), self.tr('Processing'), QgsMessageLog.WARNING)
output_feature.setGeometry(output_geometry)

writer.addFeature(output_feature)
@@ -141,10 +141,9 @@ def processAlgorithm(self, context, feedback):
out_feat.setAttributes(in_feat.attributes())
writer.addFeature(out_feat)
except:
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL,
self.tr('Feature geometry error: One or more '
'output features ignored due to '
'invalid geometry.'))
QgsMessageLog.logMessage(self.tr('Feature geometry error: One or more '
'output features ignored due to '
'invalid geometry.'), self.tr('Processing'), QgsMessageLog.CRITICAL)
continue

if single_clip_feature:
@@ -102,8 +102,7 @@ def processAlgorithm(self, context, feedback):
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
QgsProcessingUtils.logMessage(QgsMessageLog.WARNING,
self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'))
QgsMessageLog.logMessage(self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'), self.tr('Processing'), QgsMessageLog.WARNING)
continue

feedback.setProgress(int(current * total))
@@ -108,12 +108,11 @@ def processAlgorithm(self, context, feedback):
errors = tmpInGeom.validateGeometry()
if len(errors) != 0:
for error in errors:
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL,
self.tr('ValidateGeometry()'
'error: One or more '
'input features have '
'invalid geometry: ') +
error.what())
QgsMessageLog.logMessage(self.tr('ValidateGeometry()'
'error: One or more '
'input features have '
'invalid geometry: ') +
error.what(), self.tr('Processing'), QgsMessageLog.CRITICAL)
continue

geom_queue.append(tmpInGeom)
@@ -151,12 +150,11 @@ def processAlgorithm(self, context, feedback):
errors = tmpInGeom.validateGeometry()
if len(errors) != 0:
for error in errors:
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL,
self.tr('ValidateGeometry() '
'error: One or more input'
'features have invalid '
'geometry: ') +
error.what())
QgsMessageLog.logMessage(self.tr('ValidateGeometry() '
'error: One or more input'
'features have invalid '
'geometry: ') +
error.what(), self.tr('Processing'), QgsMessageLog.CRITICAL)

if index_attrs not in attribute_dict:
# keep attributes of first feature
@@ -86,8 +86,8 @@ def processAlgorithm(self, context, feedback):
smallestArea = self.getParameterValue(self.MODE) == self.MODE_SMALLEST_AREA

if inLayer.selectedFeatureCount() == 0:
QgsProcessingUtils.logMessage(QgsMessageLog.WARNING,
self.tr('{0}: (No selection in input layer "{1}")').format(self.displayName(), self.getParameterValue(self.INPUT)))
QgsMessageLog.logMessage(self.tr('{0}: (No selection in input layer "{1}")').format(self.displayName(), self.getParameterValue(self.INPUT)),
self.tr('Processing'), QgsMessageLog.WARNING)

featToEliminate = []
selFeatIds = inLayer.selectedFeatureIds()
@@ -88,8 +88,7 @@ def processAlgorithm(self, context, feedback):
if inputFeature.geometry():
outputGeometry = inputFeature.geometry().makeValid()
if not outputGeometry:
QgsProcessingUtils.logMessage(QgsMessageLog.WARNING,
'makeValid failed for feature {}'.format(inputFeature.id()))
QgsMessageLog.logMessage('makeValid failed for feature {}'.format(inputFeature.id()), self.tr('Processing'), QgsMessageLog.WARNING)

if outputGeometry.wkbType() == QgsWkbTypes.Unknown or QgsWkbTypes.flatType(outputGeometry.geometry().wkbType()) == QgsWkbTypes.GeometryCollection:
tmpGeometries = outputGeometry.asGeometryCollection()
@@ -100,8 +100,7 @@ def processAlgorithm(self, context, feedback):
elif geomType == QgsWkbTypes.LineString:
points = self._gridify(geom.asPolyline(), hSpacing, vSpacing)
if len(points) < 2:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Failed to gridify feature with FID {0}').format(f.id()))
QgsMessageLog.logMessage(self.tr('Failed to gridify feature with FID {0}').format(f.id()), self.tr('Processing'), QgsMessageLog.INFO)
newGeom = None
else:
newGeom = QgsGeometry.fromPolyline(points)
@@ -112,8 +111,7 @@ def processAlgorithm(self, context, feedback):
if len(points) > 1:
polyline.append(points)
if len(polyline) <= 0:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Failed to gridify feature with FID {0}').format(f.id()))
QgsMessageLog.logMessage(self.tr('Failed to gridify feature with FID {0}').format(f.id()), self.tr('Processing'), QgsMessageLog.INFO)
newGeom = None
else:
newGeom = QgsGeometry.fromMultiPolyline(polyline)
@@ -125,8 +123,7 @@ def processAlgorithm(self, context, feedback):
if len(points) > 1:
polygon.append(points)
if len(polygon) <= 0:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Failed to gridify feature with FID {0}').format(f.id()))
QgsMessageLog.logMessage(self.tr('Failed to gridify feature with FID {0}').format(f.id()), self.tr('Processing'), QgsMessageLog.INFO)
newGeom = None
else:
newGeom = QgsGeometry.fromPolygon(polygon)
@@ -143,8 +140,7 @@ def processAlgorithm(self, context, feedback):
multipolygon.append(newPolygon)

if len(multipolygon) <= 0:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Failed to gridify feature with FID {0}').format(f.id()))
QgsMessageLog.logMessage(self.tr('Failed to gridify feature with FID {0}').format(f.id()), self.tr('Processing'), QgsMessageLog.INFO)
newGeom = None
else:
newGeom = QgsGeometry.fromMultiPolygon(multipolygon)
@@ -176,8 +176,7 @@ def processAlgorithm(self, context, feedback):
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, f in enumerate(features):
if kde.addFeature(f) != QgsKernelDensityEstimation.Success:
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL,
self.tr('Error adding feature with ID {} to heatmap').format(f.id()))
QgsMessageLog.logMessage(self.tr('Error adding feature with ID {} to heatmap').format(f.id()), self.tr('Processing'), QgsMessageLog.CRITICAL)

feedback.setProgress(int(current * total))

@@ -117,10 +117,9 @@ def processAlgorithm(self, context, feedback):
int_sym = geom.symDifference(tmpGeom)
int_geom = QgsGeometry(int_com.difference(int_sym))
if int_geom.isEmpty() or not int_geom.isGeosValid():
QgsProcessingUtils.logMessage(QgsMessageLog.CRITICAL,
self.tr('GEOS geoprocessing error: One or '
'more input features have invalid '
'geometry.'))
QgsMessageLog.logMessage(self.tr('GEOS geoprocessing error: One or '
'more input features have invalid '
'geometry.'), self.tr('Processing'), QgsMessageLog.CRITICAL)
try:
if int_geom.wkbType() in wkbTypeGroups[wkbTypeGroups[int_geom.wkbType()]]:
outFeat.setGeometry(int_geom)
@@ -130,8 +129,7 @@ def processAlgorithm(self, context, feedback):
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'))
QgsMessageLog.logMessage(self.tr('Feature geometry error: One or more output features ignored due to invalid geometry.'), self.tr('Processing'), QgsMessageLog.INFO)
continue

del writer
@@ -151,8 +151,7 @@ def processAlgorithm(self, context, feedback):
nIterations += 1

if nPoints < pointCount:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'))
QgsMessageLog.logMessage(self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'), self.tr('Processing'), QgsMessageLog.INFO)

del writer
@@ -131,8 +131,7 @@ def processAlgorithm(self, context, feedback):
nIterations += 1

if nPoints < pointCount:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'))
QgsMessageLog.logMessage(self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'), self.tr('Processing'), QgsMessageLog.INFO)

del writer
@@ -122,8 +122,7 @@ def processAlgorithm(self, context, feedback):
nIterations += 1

if nPoints < pointCount:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'))
QgsMessageLog.logMessage(self.tr('Can not generate requested number of random points. '
'Maximum number of attempts exceeded.'), self.tr('Processing'), QgsMessageLog.INFO)

del writer
@@ -138,9 +138,8 @@ def processAlgorithm(self, context, feedback):
nIterations += 1

if nPoints < pointCount:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Can not generate requested number of random '
'points. Maximum number of attempts exceeded.'))
QgsMessageLog.logMessage(self.tr('Can not generate requested number of random '
'points. Maximum number of attempts exceeded.'), self.tr('Processing'), QgsMessageLog.INFO)

feedback.setProgress(0)

@@ -139,9 +139,8 @@ def processAlgorithm(self, context, feedback):
nIterations += 1

if nPoints < pointCount:
QgsProcessingUtils.logMessage(QgsMessageLog.INFO,
self.tr('Can not generate requested number of random '
'points. Maximum number of attempts exceeded.'))
QgsMessageLog.logMessage(self.tr('Can not generate requested number of random '
'points. Maximum number of attempts exceeded.'), self.tr('Processing'), QgsMessageLog.INFO)

feedback.setProgress(0)

Loading

0 comments on commit e9f13d1

Please sign in to comment.