Skip to content
Permalink
Browse files

[processing][grass] Fix handling of optional file parameters

  • Loading branch information
nyalldawson committed May 31, 2018
1 parent e273ac2 commit 0e7c31e9e7d425eab3f05a7c8fd9962257961260
@@ -612,17 +612,18 @@ def processCommand(self, parameters, context, feedback, delOutputs=False):
outName = out.name()
# For File destination
if isinstance(out, QgsProcessingParameterFileDestination):
# for HTML reports, we need to redirect stdout
if out.defaultFileExtension().lower() == 'html':
command += ' > "{}"'.format(
self.parameterAsFileOutput(
parameters, outName, context)
)
else:
command += ' {}="{}"'.format(
outName,
self.parameterAsFileOutput(
parameters, outName, context))
if outName in parameters and parameters[outName] is not None:
# for HTML reports, we need to redirect stdout
if out.defaultFileExtension().lower() == 'html':
command += ' > "{}"'.format(
self.parameterAsFileOutput(
parameters, outName, context)
)
else:
command += ' {}="{}"'.format(
outName,
self.parameterAsFileOutput(
parameters, outName, context))
# For folders destination
elif isinstance(out, QgsProcessingParameterFolderDestination):
# We need to add a unique temporary basename
@@ -10,4 +10,4 @@ QgsProcessingParameterNumber|convergence|Percent convergence|QgsProcessingParame
QgsProcessingParameterNumber|separation|Cluster separation|QgsProcessingParameterNumber.Double|0.0|True|0.0|None
QgsProcessingParameterNumber|min_size|Minimum number of pixels in a class|QgsProcessingParameterNumber.Integer|17|True|1|None
QgsProcessingParameterFileDestination|signaturefile|Signature File|Txt files (*.txt)|None|False
QgsProcessingParameterFileDestination|reportfile|Final Report File|Txt files (*.txt)|None|False
QgsProcessingParameterFileDestination|reportfile|Final Report File|Txt files (*.txt)|None|True
@@ -258,39 +258,39 @@ tests:
hash: e1a433546cc1fdf7061adc0d9b77676c9d66ee8e0773d471bdb39a37
type: rasterhash

# - algorithm: grass7:i.cluster
# name: GRASS7 i.cluster
# params:
# GRASS_REGION_PARAMETER: '344500.0,358400.0,6682800.0,6693700.0'
# classes: 5
# convergence: 98
# input:
# params:
# - name: custom/grass7/raster_6class.tif
# type: raster
# - name: custom/grass7/raster_5class.tif
# type: raster
# - name: custom/grass7/raster_4class.tif
# type: raster
# type: multi
# iterations: 30
# min_size: 17
# separation: 0
# results:
# signaturefile:
# type: regex
# name: expected/grass7/i.cluster.sig.txt
# rules:
# - '#Class 1'
# - '1.83333 1.53759 3.31579'
# - '#Class 2'
# - '2.11045 4.35498 3.32266'
# - '#Class 3'
# - '5.32655 1.72558 3.32713'
# - '#Class 4'
# - '4.34567 4.36522 3.30235'
# - '#Class 5'
# - '6 4.55734 3.30291'
- algorithm: grass7:i.cluster
name: GRASS7 i.cluster
params:
GRASS_REGION_PARAMETER: '344500.0,358400.0,6682800.0,6693700.0'
classes: 5
convergence: 98
input:
params:
- name: custom/grass7/raster_6class.tif
type: raster
- name: custom/grass7/raster_5class.tif
type: raster
- name: custom/grass7/raster_4class.tif
type: raster
type: multi
iterations: 30
min_size: 17
separation: 0
results:
signaturefile:
type: regex
name: expected/grass7/i.cluster.sig.txt
rules:
- '#Class 1'
- '1.83333 1.53759 3.31579'
- '#Class 2'
- '2.11045 4.35498 3.32266'
- '#Class 3'
- '5.32655 1.72558 3.32713'
- '#Class 4'
- '4.34567 4.36522 3.30235'
- '#Class 5'
- '6 4.55734 3.30291'

- algorithm: grass7:i.oif
name: GRASS7 i.oif

0 comments on commit 0e7c31e

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