Skip to content

Commit

Permalink
[processing][grass] Push feedback object to algorithm methods
Browse files Browse the repository at this point in the history
(cherry-picked from c50a039)
  • Loading branch information
nyalldawson committed Apr 9, 2018
1 parent a171b23 commit d95c21e
Show file tree
Hide file tree
Showing 91 changed files with 243 additions and 243 deletions.
14 changes: 7 additions & 7 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -365,9 +365,9 @@ def processAlgorithm(self, parameters, context, feedback):
for fName in ['Inputs', 'Command', 'Outputs']:
fullName = 'process{}'.format(fName)
if self.module and hasattr(self.module, fullName):
getattr(self.module, fullName)(self, parameters, context)
getattr(self.module, fullName)(self, parameters, context, feedback)
else:
getattr(self, fullName)(parameters, context)
getattr(self, fullName)(parameters, context, feedback)

# Run GRASS
loglines = []
Expand Down Expand Up @@ -398,7 +398,7 @@ def processAlgorithm(self, parameters, context, feedback):

return outputs

def processInputs(self, parameters, context):
def processInputs(self, parameters, context, feedback):
"""Prepare the GRASS import commands"""
inputs = [p for p in self.parameterDefinitions()
if isinstance(p, (QgsProcessingParameterVectorLayer,
Expand Down Expand Up @@ -428,7 +428,7 @@ def processInputs(self, parameters, context):
paramName, parameters, context)
else:
self.loadVectorLayerFromParameter(
paramName, parameters, context, None)
paramName, parameters, context, feedback, None)
# For multiple inputs, process each layer
elif isinstance(param, QgsProcessingParameterMultipleLayers):
layers = self.parameterAsLayerList(parameters, paramName, context)
Expand Down Expand Up @@ -474,7 +474,7 @@ def postInputs(self):

QgsMessageLog.logMessage(self.tr('processInputs end. Commands: {}').format(self.commands), 'Grass7', Qgis.Info)

def processCommand(self, parameters, context, delOutputs=False):
def processCommand(self, parameters, context, feedback, delOutputs=False):
"""
Prepare the GRASS algorithm command
:param parameters:
Expand Down Expand Up @@ -622,7 +622,7 @@ def vectorOutputType(self, parameters, context):
self.outType = ('auto' if typeidx
is None else self.OUTPUT_TYPES[typeidx])

def processOutputs(self, parameters, context):
def processOutputs(self, parameters, context, feedback):
"""Prepare the GRASS v.out.ogr commands"""
# TODO: support multiple raster formats.
# TODO: support multiple vector formats.
Expand Down Expand Up @@ -751,7 +751,7 @@ def exportRasterLayersIntoDirectory(self, name, parameters, context, colorTable=
)
cmd.append("done")

def loadVectorLayerFromParameter(self, name, parameters, context, external=False):
def loadVectorLayerFromParameter(self, name, parameters, context, feedback, external=False):
"""
Creates a dedicated command to load a vector into
the temporary GRASS DB.
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_cca.py
Expand Up @@ -32,7 +32,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'input', 2, 8)


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context,
'input', 'group', 'subgroup')
Expand All @@ -42,4 +42,4 @@ def processCommand(alg, parameters, context):
parameters['signature'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_cluster.py
Expand Up @@ -33,15 +33,15 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'input', 2)


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/grass7/ext/i_colors_enhance.py
Expand Up @@ -28,12 +28,12 @@
from .i import exportInputRasters


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Temporary remove outputs:
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Input rasters are output rasters
rasterDic = {'red': 'redoutput', 'green': 'greenoutput', 'blue': 'blueoutput'}
exportInputRasters(alg, parameters, context, rasterDic)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_gensig.py
Expand Up @@ -29,15 +29,15 @@
from .i import regroupRasters, exportSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_gensigset.py
Expand Up @@ -29,15 +29,15 @@
from .i import regroupRasters, exportSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to extract the basename of the signature file
signatureFile = alg.parameterAsString(parameters, 'signaturefile', context)
shortSigFile = os.path.basename(signatureFile)
parameters['signaturefile'] = shortSigFile

# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)

# Re-add signature files
parameters['signaturefile'] = signatureFile
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/i_in_spotvgt.py
Expand Up @@ -26,7 +26,7 @@
__revision__ = '$Format:%H$'


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# Here, we apply directly the algorithm
# So we just need to get the projection of the layer !
layer = alg.parameterAsRasterLayer(parameters, 'input', context)
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/grass7/ext/i_landsat_acca.py
Expand Up @@ -32,10 +32,10 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'rasters', 5, 5)


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
orderedInput(alg, parameters, context, 'rasters', 'input',
[2, 3, 4, 5, 61])


def processCommand(alg, parameters, context):
alg.processCommand(parameters, context)
def processCommand(alg, parameters, context, feedback):
alg.processCommand(parameters, context, feedback)
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/grass7/ext/i_landsat_toar.py
Expand Up @@ -32,10 +32,10 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return verifyRasterNum(alg, parameters, context, 'rasters', 5, 12)


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
orderedInput(alg, parameters, context, 'rasters', 'input',
[1, 2, 3, 4, 5, 61, 62, 7, 8])


def processCommand(alg, parameters, context):
alg.processCommand(parameters, context)
def processCommand(alg, parameters, context, feedback):
alg.processCommand(parameters, context, feedback)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_maxlik.py
Expand Up @@ -28,7 +28,7 @@
from .i import regroupRasters, importSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
group, subgroup = regroupRasters(alg, parameters, context,
'input', 'group', 'subgroup')

Expand All @@ -38,4 +38,4 @@ def processCommand(alg, parameters, context):
parameters['signaturefile'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/grass7/ext/i_pansharpen.py
Expand Up @@ -31,16 +31,16 @@
from qgis.core import QgsProcessingParameterString


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Temporary remove outputs and add a virtual output parameter
outputName = 'output_{}'.format(os.path.basename(getTempFilename()))
param = QgsProcessingParameterString('output', 'virtual output',
outputName, False, False)
alg.addParameter(param)
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
outputName = alg.parameterAsString(parameters, 'output', context)
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_segment.py
Expand Up @@ -28,7 +28,7 @@
from .i import regroupRasters


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
regroupRasters(alg, parameters, context, 'input', 'group')
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/i_smap.py
Expand Up @@ -28,7 +28,7 @@
from .i import regroupRasters, importSigFile


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Regroup rasters
group, subgroup = regroupRasters(alg, parameters, context, 'input', 'group', 'subgroup')

Expand All @@ -38,4 +38,4 @@ def processCommand(alg, parameters, context):
parameters['signaturefile'] = shortSigFile

# Handle other parameters
alg.processCommand(parameters, context)
alg.processCommand(parameters, context, feedback)
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/r_blend_combine.py
Expand Up @@ -26,7 +26,7 @@
__revision__ = '$Format:%H$'


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
if 'first' and 'second' in alg.exportedLayers:
return

Expand All @@ -36,6 +36,6 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Keep color table
alg.exportRasterLayerFromParameter('output', parameters, context)
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/grass7/ext/r_blend_rgb.py
Expand Up @@ -30,7 +30,7 @@
from processing.algs.grass7.Grass7Utils import Grass7Utils


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
if 'first' and 'second' in alg.exportedLayers:
return

Expand All @@ -40,12 +40,12 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to remove all outputs
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/grass7/ext/r_category.py
Expand Up @@ -43,7 +43,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# If there is another raster to copy categories from
# we need to import it with r.in.gdal rather than r.external
raster = alg.parameterAsString(parameters, 'raster', context)
Expand All @@ -55,7 +55,7 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Handle inline rules
txtRules = alg.parameterAsString(parameters, 'txtrules', context)
if txtRules:
Expand All @@ -68,10 +68,10 @@ def processCommand(alg, parameters, context):
alg.removeParameter('txtrules')
parameters['rules'] = tempRulesName

alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# Output results ('map' layer)
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/grass7/ext/r_colors.py
Expand Up @@ -39,7 +39,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# import all rasters with their color tables (and their bands)
# We need to import all the bands and color tables of the input rasters
rasters = alg.parameterAsLayerList(parameters, 'map', context)
Expand All @@ -56,7 +56,7 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# Handle inline rules
txtRules = alg.parameterAsString(parameters, 'txtrules', context)
if txtRules:
Expand All @@ -69,10 +69,10 @@ def processCommand(alg, parameters, context):
alg.removeParameter('txtrules')
parameters['rules'] = tempRulesName

alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/grass7/ext/r_colors_stddev.py
Expand Up @@ -28,7 +28,7 @@
from processing.algs.grass7.Grass7Utils import Grass7Utils


def processInputs(alg, parameters, context):
def processInputs(alg, parameters, context, feedback):
# We need to import all the bands and to preserve color table
if 'map' in alg.exportedLayers:
return
Expand All @@ -38,12 +38,12 @@ def processInputs(alg, parameters, context):
alg.postInputs()


def processCommand(alg, parameters, context):
def processCommand(alg, parameters, context, feedback):
# We need to remove output
alg.processCommand(parameters, context, True)
alg.processCommand(parameters, context, feedback, True)


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
createOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_OPT, context)
metaOpt = alg.parameterAsString(parameters, alg.GRASS_RASTER_FORMAT_META, context)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/r_horizon.py
Expand Up @@ -40,7 +40,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
return None


def processOutputs(alg, parameters, context):
def processOutputs(alg, parameters, context, feedback):
# There will be as many outputs as the difference between start and end divided by steps
start = alg.parameterAsDouble(parameters, 'start', context)
end = alg.parameterAsDouble(parameters, 'end', context)
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/r_li.py
Expand Up @@ -84,7 +84,7 @@ def checkMovingWindow(alg, parameters, context, outputTxt=False):
return None


def configFile(alg, parameters, context, outputTxt=False):
def configFile(alg, parameters, context, feedback, outputTxt=False):
"""Handle inline configuration
:param parameters:
"""
Expand Down Expand Up @@ -125,7 +125,7 @@ def configFile(alg, parameters, context, outputTxt=False):
False, False)
alg.addParameter(param)

alg.processCommand(parameters, context, outputTxt)
alg.processCommand(parameters, context, feedback, outputTxt)

# Remove Config file:
removeConfigFile(alg, parameters, context)
Expand Down

0 comments on commit d95c21e

Please sign in to comment.