mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Merge pull request #36618 from alexbruy/grass-tempfile
[processing] fix handling for stdout and file outputs in GRASS
This commit is contained in:
commit
585db6440f
@ -116,6 +116,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
self.commands = []
|
||||
self.outputCommands = []
|
||||
self.exportedLayers = {}
|
||||
self.fileOutputs = {}
|
||||
self.descriptionFile = descriptionfile
|
||||
|
||||
# Default GRASS parameters
|
||||
@ -398,6 +399,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
self.commands = []
|
||||
self.outputCommands = []
|
||||
self.exportedLayers = {}
|
||||
self.fileOutputs = {}
|
||||
|
||||
# If GRASS session has been created outside of this algorithm then
|
||||
# get the list of layers loaded in GRASS otherwise start a new
|
||||
@ -442,9 +444,15 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
for out in self.outputDefinitions():
|
||||
outName = out.name()
|
||||
if outName in parameters:
|
||||
outputs[outName] = parameters[outName]
|
||||
if outName in self.fileOutputs:
|
||||
print('ADD', outName)
|
||||
print('VAL', parameters[outName])
|
||||
print('VAL 2', self.fileOutputs[outName])
|
||||
outputs[outName] = self.fileOutputs[outName]
|
||||
else:
|
||||
outputs[outName] = parameters[outName]
|
||||
if isinstance(out, QgsProcessingOutputHtml):
|
||||
self.convertToHtml(parameters[outName])
|
||||
self.convertToHtml(self.fileOutputs[outName])
|
||||
|
||||
return outputs
|
||||
|
||||
@ -643,23 +651,18 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
# For File destination
|
||||
if isinstance(out, QgsProcessingParameterFileDestination):
|
||||
if outName in parameters and parameters[outName] is not None:
|
||||
outPath = self.parameterAsFileOutput(parameters, outName, context)
|
||||
self.fileOutputs[outName] = outPath
|
||||
# for HTML reports, we need to redirect stdout
|
||||
if out.defaultFileExtension().lower() == 'html':
|
||||
if outName == 'html':
|
||||
# for "fake" outputs redirect command stdout
|
||||
command += ' > "{}"'.format(
|
||||
self.parameterAsFileOutput(
|
||||
parameters, outName, context)
|
||||
)
|
||||
command += ' > "{}"'.format(outPath)
|
||||
else:
|
||||
# for real outputs only output itself should be redirected
|
||||
command += ' {}=- > "{}"'.format(
|
||||
outName,
|
||||
self.parameterAsFileOutput(parameters, outName, context))
|
||||
command += ' {}=- > "{}"'.format(outName, outPath)
|
||||
else:
|
||||
command += ' {}="{}"'.format(
|
||||
outName,
|
||||
self.parameterAsFileOutput(parameters, outName, context))
|
||||
command += ' {}="{}"'.format(outName, outPath)
|
||||
# For folders destination
|
||||
elif isinstance(out, QgsProcessingParameterFolderDestination):
|
||||
# We need to add a unique temporary basename
|
||||
|
@ -41,6 +41,7 @@ def processCommand(alg, parameters, context, feedback):
|
||||
|
||||
# Re-add signature files
|
||||
parameters['signaturefile'] = signatureFile
|
||||
alg.fileOutputs['signaturefile'] = signatureFile
|
||||
|
||||
# Export signature file
|
||||
exportSigFile(alg, group, subgroup, signatureFile)
|
||||
|
@ -37,6 +37,7 @@ def processCommand(alg, parameters, context, feedback):
|
||||
|
||||
# Re-add signature files
|
||||
parameters['signaturefile'] = signatureFile
|
||||
alg.fileOutputs['signaturefile'] = signatureFile
|
||||
|
||||
# Export signature file
|
||||
exportSigFile(alg, group, subgroup, signatureFile)
|
||||
|
@ -37,6 +37,7 @@ def processCommand(alg, parameters, context, feedback):
|
||||
|
||||
# Re-add signature files
|
||||
parameters['signaturefile'] = signatureFile
|
||||
alg.fileOutputs['signaturefile'] = signatureFile
|
||||
|
||||
# Export signature file
|
||||
exportSigFile(alg, group, subgroup, signatureFile, 'sigset')
|
||||
|
Loading…
x
Reference in New Issue
Block a user