Skip to content
Permalink
Browse files

[processing] Fix exception when clicking help for GDAL algorithms

  • Loading branch information
nyalldawson committed May 5, 2018
1 parent 280018d commit b3288192ee2cd216b936dda98fc6600f27993d39
Showing with 140 additions and 24 deletions.
  1. +3 −0 python/plugins/processing/algs/gdal/AssignProjection.py
  2. +4 −1 python/plugins/processing/algs/gdal/ClipRasterByMask.py
  3. +4 −1 python/plugins/processing/algs/gdal/ColorRelief.py
  4. +6 −4 python/plugins/processing/algs/gdal/GdalAlgorithm.py
  5. +4 −1 python/plugins/processing/algs/gdal/aspect.py
  6. +4 −1 python/plugins/processing/algs/gdal/contour.py
  7. +3 −0 python/plugins/processing/algs/gdal/fillnodata.py
  8. +3 −0 python/plugins/processing/algs/gdal/gdal2tiles.py
  9. +3 −1 python/plugins/processing/algs/gdal/gdal2xyz.py
  10. +4 −1 python/plugins/processing/algs/gdal/gdaladdo.py
  11. +4 −1 python/plugins/processing/algs/gdal/gdalinfo.py
  12. +4 −1 python/plugins/processing/algs/gdal/gdaltindex.py
  13. +4 −1 python/plugins/processing/algs/gdal/hillshade.py
  14. +4 −1 python/plugins/processing/algs/gdal/nearblack.py
  15. +4 −2 python/plugins/processing/algs/gdal/ogrinfo.py
  16. +3 −0 python/plugins/processing/algs/gdal/pct2rgb.py
  17. +3 −0 python/plugins/processing/algs/gdal/polygonize.py
  18. +3 −0 python/plugins/processing/algs/gdal/proximity.py
  19. +3 −0 python/plugins/processing/algs/gdal/rgb2pct.py
  20. +4 −1 python/plugins/processing/algs/gdal/roughness.py
  21. +3 −0 python/plugins/processing/algs/gdal/sieve.py
  22. +4 −1 python/plugins/processing/algs/gdal/slope.py
  23. +4 −1 python/plugins/processing/algs/gdal/tpi.py
  24. +4 −1 python/plugins/processing/algs/gdal/translate.py
  25. +4 −1 python/plugins/processing/algs/gdal/tri.py
  26. +4 −1 python/plugins/processing/algs/gdal/warp.py
  27. +36 −2 python/plugins/processing/tests/AlgorithmsTestBase.py
  28. +1 −0 python/plugins/processing/tests/CMakeLists.txt
  29. +6 −0 python/plugins/processing/tests/GdalAlgorithmsTest.py
@@ -73,6 +73,9 @@ def group(self):
def groupId(self):
return 'rasterprojections'

def commandName(self):
return 'gdal_edit'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
fileName = inLayer.source()
@@ -119,6 +119,9 @@ def group(self):
def groupId(self):
return 'rasterextraction'

def commandName(self):
return 'gdalwarp'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)

@@ -159,4 +162,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())
arguments.append(out)

return ['gdalwarp', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -96,6 +96,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['color-relief']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -116,4 +119,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append(self.modes[self.parameterAsEnum(parameters, self.MATCH_MODE, context)][1])

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -32,7 +32,9 @@

from qgis.core import (QgsApplication,
QgsVectorFileWriter,
QgsProcessingAlgorithm)
QgsProcessingAlgorithm,
QgsProcessingContext,
QgsProcessingFeedback)

from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog
from processing.algs.gdal.GdalUtils import GdalUtils
@@ -136,11 +138,11 @@ def helpUrl(self):

def commandName(self):
parameters = {}
for output in self.outputs:
output.setValue("dummy")
for param in self.parameterDefinitions():
parameters[param.name()] = "1"
name = self.getConsoleCommands(parameters)[0]
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
name = self.getConsoleCommands(parameters, context, feedback, executing=False)[0]
if name.endswith(".py"):
name = name[:-3]
return name
@@ -96,6 +96,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['aspect']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -127,4 +130,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -121,6 +121,9 @@ def group(self):
def groupId(self):
return 'rasterextraction'

def commandName(self):
return 'gdal_contour'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
fieldName = self.parameterAsString(parameters, self.FIELD_NAME, context)
@@ -159,4 +162,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())
arguments.append(output)

return ['gdal_contour', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -89,6 +89,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdal_fillnodata'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-md')
@@ -154,6 +154,9 @@ def group(self):
def groupId(self):
return 'rastermiscellaneous'

def commandName(self):
return 'gdal2tiles'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []

@@ -71,8 +71,10 @@ def group(self):
def groupId(self):
return 'rasterconversion'

def commandName(self):
return 'gdal2xyz'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments = []
arguments.append('-band')
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))
@@ -105,6 +105,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png'))

def commandName(self):
return 'gdaladdo'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
fileName = inLayer.source()
@@ -128,4 +131,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

self.setOutputValue(self.OUTPUT, fileName)

return ['gdaladdo', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -84,6 +84,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))

def commandName(self):
return 'gdalinfo'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
if self.parameterAsBool(parameters, self.MIN_MAX, context):
@@ -95,7 +98,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if self.parameterAsBool(parameters, self.NO_METADATA, context):
arguments.append('-nomd')
arguments.append(self.parameterAsRasterLayer(parameters, self.INPUT, context).source())
return ['gdalinfo', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

def processAlgorithm(self, parameters, context, feedback):
GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback)
@@ -117,6 +117,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'tiles.png'))

def commandName(self):
return 'gdaltindex'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
input_layers = self.parameterAsLayerList(parameters, self.LAYERS, context)
crs_field = self.parameterAsString(parameters, self.CRS_FIELD_NAME, context)
@@ -158,4 +161,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(output)
arguments.append(' '.join(layers))

return ['gdaltindex', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -123,6 +123,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['hillshade']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -162,4 +165,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -92,6 +92,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'nearblack.png'))

def commandName(self):
return 'nearblack'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)

@@ -114,4 +117,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['nearblack', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -69,9 +69,11 @@ def group(self):
def groupId(self):
return 'vectormiscellaneous'

def commandName(self):
return 'ogrinfo'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['ogrinfo']
arguments.append('-al')
arguments = [self.commandName(), '-al']

if self.parameterAsBool(parameters, self.SUMMARY_ONLY, context):
arguments.append('-so')
@@ -77,6 +77,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '8-to-24-bits.png'))

def commandName(self):
return 'pct2rgb'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -85,6 +85,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png'))

def commandName(self):
return 'gdal_polygonize'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -131,6 +131,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdal_proximity'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
distance = self.parameterAsDouble(parameters, self.MAX_DISTANCE, context)
@@ -76,6 +76,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '24-to-8-bits.png'))

def commandName(self):
return 'rgb2pct'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-n')
@@ -85,6 +85,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['roughness']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -107,4 +110,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-co')
arguments.append(options)

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -87,6 +87,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'sieve.png'))

def commandName(self):
return 'gdal_sieve'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = []
arguments.append('-st')
@@ -100,6 +100,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['slope']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -131,4 +134,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -84,6 +84,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['TPI']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -101,4 +104,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -110,6 +110,9 @@ def groupId(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png'))

def commandName(self):
return 'gdal_translate'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
@@ -145,4 +148,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())
arguments.append(out)

return ['gdal_translate', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -83,6 +83,9 @@ def group(self):
def groupId(self):
return 'rasteranalysis'

def commandName(self):
return 'gdaldem'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments = ['TRI']
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -100,4 +103,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if options:
arguments.extend(GdalUtils.parseCreationOptions(options))

return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
@@ -158,6 +158,9 @@ def icon(self):
def tags(self):
return self.tr('transform,reproject,crs,srs').split(',')

def commandName(self):
return 'gdalwarp'

def getConsoleCommands(self, parameters, context, feedback, executing=True):
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
@@ -217,4 +220,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source())
arguments.append(out)

return ['gdalwarp', GdalUtils.escapeAndJoin(arguments)]
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

0 comments on commit b328819

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