Skip to content

Commit b328819

Browse files
committed
[processing] Fix exception when clicking help for GDAL algorithms
1 parent 280018d commit b328819

29 files changed

+140
-24
lines changed

python/plugins/processing/algs/gdal/AssignProjection.py

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def group(self):
7373
def groupId(self):
7474
return 'rasterprojections'
7575

76+
def commandName(self):
77+
return 'gdal_edit'
78+
7679
def getConsoleCommands(self, parameters, context, feedback, executing=True):
7780
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
7881
fileName = inLayer.source()

python/plugins/processing/algs/gdal/ClipRasterByMask.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def group(self):
119119
def groupId(self):
120120
return 'rasterextraction'
121121

122+
def commandName(self):
123+
return 'gdalwarp'
124+
122125
def getConsoleCommands(self, parameters, context, feedback, executing=True):
123126
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
124127

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

162-
return ['gdalwarp', GdalUtils.escapeAndJoin(arguments)]
165+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/ColorRelief.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def group(self):
9696
def groupId(self):
9797
return 'rasteranalysis'
9898

99+
def commandName(self):
100+
return 'gdaldem'
101+
99102
def getConsoleCommands(self, parameters, context, feedback, executing=True):
100103
arguments = ['color-relief']
101104
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -116,4 +119,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
116119

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

119-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
122+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/GdalAlgorithm.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232

3333
from qgis.core import (QgsApplication,
3434
QgsVectorFileWriter,
35-
QgsProcessingAlgorithm)
35+
QgsProcessingAlgorithm,
36+
QgsProcessingContext,
37+
QgsProcessingFeedback)
3638

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

137139
def commandName(self):
138140
parameters = {}
139-
for output in self.outputs:
140-
output.setValue("dummy")
141141
for param in self.parameterDefinitions():
142142
parameters[param.name()] = "1"
143-
name = self.getConsoleCommands(parameters)[0]
143+
context = QgsProcessingContext()
144+
feedback = QgsProcessingFeedback()
145+
name = self.getConsoleCommands(parameters, context, feedback, executing=False)[0]
144146
if name.endswith(".py"):
145147
name = name[:-3]
146148
return name

python/plugins/processing/algs/gdal/aspect.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ def group(self):
9696
def groupId(self):
9797
return 'rasteranalysis'
9898

99+
def commandName(self):
100+
return 'gdaldem'
101+
99102
def getConsoleCommands(self, parameters, context, feedback, executing=True):
100103
arguments = ['aspect']
101104
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -127,4 +130,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
127130
if options:
128131
arguments.extend(GdalUtils.parseCreationOptions(options))
129132

130-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
133+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/contour.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def group(self):
121121
def groupId(self):
122122
return 'rasterextraction'
123123

124+
def commandName(self):
125+
return 'gdal_contour'
126+
124127
def getConsoleCommands(self, parameters, context, feedback, executing=True):
125128
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
126129
fieldName = self.parameterAsString(parameters, self.FIELD_NAME, context)
@@ -159,4 +162,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
159162
arguments.append(inLayer.source())
160163
arguments.append(output)
161164

162-
return ['gdal_contour', GdalUtils.escapeAndJoin(arguments)]
165+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/fillnodata.py

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def group(self):
8989
def groupId(self):
9090
return 'rasteranalysis'
9191

92+
def commandName(self):
93+
return 'gdal_fillnodata'
94+
9295
def getConsoleCommands(self, parameters, context, feedback, executing=True):
9396
arguments = []
9497
arguments.append('-md')

python/plugins/processing/algs/gdal/gdal2tiles.py

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ def group(self):
154154
def groupId(self):
155155
return 'rastermiscellaneous'
156156

157+
def commandName(self):
158+
return 'gdal2tiles'
159+
157160
def getConsoleCommands(self, parameters, context, feedback, executing=True):
158161
arguments = []
159162

python/plugins/processing/algs/gdal/gdal2xyz.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ def group(self):
7171
def groupId(self):
7272
return 'rasterconversion'
7373

74+
def commandName(self):
75+
return 'gdal2xyz'
76+
7477
def getConsoleCommands(self, parameters, context, feedback, executing=True):
75-
arguments = []
7678
arguments = []
7779
arguments.append('-band')
7880
arguments.append(str(self.parameterAsInt(parameters, self.BAND, context)))

python/plugins/processing/algs/gdal/gdaladdo.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def groupId(self):
105105
def icon(self):
106106
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png'))
107107

108+
def commandName(self):
109+
return 'gdaladdo'
110+
108111
def getConsoleCommands(self, parameters, context, feedback, executing=True):
109112
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
110113
fileName = inLayer.source()
@@ -128,4 +131,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
128131

129132
self.setOutputValue(self.OUTPUT, fileName)
130133

131-
return ['gdaladdo', GdalUtils.escapeAndJoin(arguments)]
134+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/gdalinfo.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def groupId(self):
8484
def icon(self):
8585
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))
8686

87+
def commandName(self):
88+
return 'gdalinfo'
89+
8790
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8891
arguments = []
8992
if self.parameterAsBool(parameters, self.MIN_MAX, context):
@@ -95,7 +98,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
9598
if self.parameterAsBool(parameters, self.NO_METADATA, context):
9699
arguments.append('-nomd')
97100
arguments.append(self.parameterAsRasterLayer(parameters, self.INPUT, context).source())
98-
return ['gdalinfo', GdalUtils.escapeAndJoin(arguments)]
101+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]
99102

100103
def processAlgorithm(self, parameters, context, feedback):
101104
GdalUtils.runGdal(self.getConsoleCommands(parameters, context, feedback), feedback)

python/plugins/processing/algs/gdal/gdaltindex.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ def groupId(self):
117117
def icon(self):
118118
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'tiles.png'))
119119

120+
def commandName(self):
121+
return 'gdaltindex'
122+
120123
def getConsoleCommands(self, parameters, context, feedback, executing=True):
121124
input_layers = self.parameterAsLayerList(parameters, self.LAYERS, context)
122125
crs_field = self.parameterAsString(parameters, self.CRS_FIELD_NAME, context)
@@ -158,4 +161,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
158161
arguments.append(output)
159162
arguments.append(' '.join(layers))
160163

161-
return ['gdaltindex', GdalUtils.escapeAndJoin(arguments)]
164+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/hillshade.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def group(self):
123123
def groupId(self):
124124
return 'rasteranalysis'
125125

126+
def commandName(self):
127+
return 'gdaldem'
128+
126129
def getConsoleCommands(self, parameters, context, feedback, executing=True):
127130
arguments = ['hillshade']
128131
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -162,4 +165,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
162165
if options:
163166
arguments.extend(GdalUtils.parseCreationOptions(options))
164167

165-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
168+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/nearblack.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def groupId(self):
9292
def icon(self):
9393
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'nearblack.png'))
9494

95+
def commandName(self):
96+
return 'nearblack'
97+
9598
def getConsoleCommands(self, parameters, context, feedback, executing=True):
9699
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
97100

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

117-
return ['nearblack', GdalUtils.escapeAndJoin(arguments)]
120+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/ogrinfo.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ def group(self):
6969
def groupId(self):
7070
return 'vectormiscellaneous'
7171

72+
def commandName(self):
73+
return 'ogrinfo'
74+
7275
def getConsoleCommands(self, parameters, context, feedback, executing=True):
73-
arguments = ['ogrinfo']
74-
arguments.append('-al')
76+
arguments = [self.commandName(), '-al']
7577

7678
if self.parameterAsBool(parameters, self.SUMMARY_ONLY, context):
7779
arguments.append('-so')

python/plugins/processing/algs/gdal/pct2rgb.py

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def groupId(self):
7777
def icon(self):
7878
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '8-to-24-bits.png'))
7979

80+
def commandName(self):
81+
return 'pct2rgb'
82+
8083
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8184
arguments = []
8285
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)

python/plugins/processing/algs/gdal/polygonize.py

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def groupId(self):
8585
def icon(self):
8686
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png'))
8787

88+
def commandName(self):
89+
return 'gdal_polygonize'
90+
8891
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8992
arguments = []
9093
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)

python/plugins/processing/algs/gdal/proximity.py

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def group(self):
131131
def groupId(self):
132132
return 'rasteranalysis'
133133

134+
def commandName(self):
135+
return 'gdal_proximity'
136+
134137
def getConsoleCommands(self, parameters, context, feedback, executing=True):
135138
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
136139
distance = self.parameterAsDouble(parameters, self.MAX_DISTANCE, context)

python/plugins/processing/algs/gdal/rgb2pct.py

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def groupId(self):
7676
def icon(self):
7777
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '24-to-8-bits.png'))
7878

79+
def commandName(self):
80+
return 'rgb2pct'
81+
7982
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8083
arguments = []
8184
arguments.append('-n')

python/plugins/processing/algs/gdal/roughness.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def group(self):
8585
def groupId(self):
8686
return 'rasteranalysis'
8787

88+
def commandName(self):
89+
return 'gdaldem'
90+
8891
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8992
arguments = ['roughness']
9093
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -107,4 +110,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
107110
arguments.append('-co')
108111
arguments.append(options)
109112

110-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
113+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/sieve.py

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def groupId(self):
8787
def icon(self):
8888
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'sieve.png'))
8989

90+
def commandName(self):
91+
return 'gdal_sieve'
92+
9093
def getConsoleCommands(self, parameters, context, feedback, executing=True):
9194
arguments = []
9295
arguments.append('-st')

python/plugins/processing/algs/gdal/slope.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ def group(self):
100100
def groupId(self):
101101
return 'rasteranalysis'
102102

103+
def commandName(self):
104+
return 'gdaldem'
105+
103106
def getConsoleCommands(self, parameters, context, feedback, executing=True):
104107
arguments = ['slope']
105108
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -131,4 +134,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
131134
if options:
132135
arguments.extend(GdalUtils.parseCreationOptions(options))
133136

134-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
137+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/tpi.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ def group(self):
8484
def groupId(self):
8585
return 'rasteranalysis'
8686

87+
def commandName(self):
88+
return 'gdaldem'
89+
8790
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8891
arguments = ['TPI']
8992
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -101,4 +104,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
101104
if options:
102105
arguments.extend(GdalUtils.parseCreationOptions(options))
103106

104-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
107+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/translate.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def groupId(self):
110110
def icon(self):
111111
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png'))
112112

113+
def commandName(self):
114+
return 'gdal_translate'
115+
113116
def getConsoleCommands(self, parameters, context, feedback, executing=True):
114117
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
115118
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
@@ -145,4 +148,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
145148
arguments.append(inLayer.source())
146149
arguments.append(out)
147150

148-
return ['gdal_translate', GdalUtils.escapeAndJoin(arguments)]
151+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/tri.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def group(self):
8383
def groupId(self):
8484
return 'rasteranalysis'
8585

86+
def commandName(self):
87+
return 'gdaldem'
88+
8689
def getConsoleCommands(self, parameters, context, feedback, executing=True):
8790
arguments = ['TRI']
8891
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
@@ -100,4 +103,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
100103
if options:
101104
arguments.extend(GdalUtils.parseCreationOptions(options))
102105

103-
return ['gdaldem', GdalUtils.escapeAndJoin(arguments)]
106+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

python/plugins/processing/algs/gdal/warp.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def icon(self):
158158
def tags(self):
159159
return self.tr('transform,reproject,crs,srs').split(',')
160160

161+
def commandName(self):
162+
return 'gdalwarp'
163+
161164
def getConsoleCommands(self, parameters, context, feedback, executing=True):
162165
inLayer = self.parameterAsRasterLayer(parameters, self.INPUT, context)
163166
out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
@@ -217,4 +220,4 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
217220
arguments.append(inLayer.source())
218221
arguments.append(out)
219222

220-
return ['gdalwarp', GdalUtils.escapeAndJoin(arguments)]
223+
return [self.commandName(), GdalUtils.escapeAndJoin(arguments)]

0 commit comments

Comments
 (0)