Skip to content
Permalink
Browse files

[processing] remove GeoAlgorithmExecutionException

  • Loading branch information
alexbruy committed Jul 13, 2017
1 parent 97a5a3d commit 56208540f9efd3acd17a9cda3ca49dca23701e45
@@ -40,12 +40,12 @@
QgsProcessingAlgorithm,
QgsProject,
QgsProcessingUtils,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsMessageLog)
from qgis.gui import QgsHelp

from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterRaster, ParameterVector, ParameterMultipleInput, ParameterTable, Parameter
from processing.core.outputs import OutputVector, OutputRaster, OutputTable, OutputHTML, Output
from processing.algs.gdal.GdalUtils import GdalUtils
@@ -76,7 +76,7 @@ def processAlgorithm(self, parameters, context, feedback):
"""Here goes the algorithm itself.
There is no return value from this method.
A GeoAlgorithmExecutionException should be raised in case
A QgsProcessingException should be raised in case
something goes wrong.
:param parameters:
:param context:
@@ -105,7 +105,7 @@ def execute(self, parameters, context=None, feedback=None, model=None):
it should be called using this method, since it performs
some additional operations.
Raises a GeoAlgorithmExecutionException in case anything goes
Raises a QgsProcessingException in case anything goes
wrong.
:param parameters:
"""
@@ -124,18 +124,18 @@ def execute(self, parameters, context=None, feedback=None, model=None):
feedback.setProgress(100)
self.convertUnsupportedFormats(context, feedback)
self.runPostExecutionScript(feedback)
except GeoAlgorithmExecutionException as gaee:
except QgsProcessingException as gaee:
lines = [self.tr('Error while executing algorithm')]
lines.append(traceback.format_exc())
QgsMessageLog.logMessage(gaee.msg, self.tr('Processing'), QgsMessageLog.CRITICAL)
raise GeoAlgorithmExecutionException(gaee.msg, lines, gaee)
raise QgsProcessingException(gaee.msg, lines, gaee)
except Exception as e:
# If something goes wrong and is not caught in the
# algorithm, we catch it here and wrap it
lines = [self.tr('Uncaught error while executing algorithm')]
lines.append(traceback.format_exc())
QgsMessageLog.logMessage('\n'.join(lines), self.tr('Processing'), QgsMessageLog.CRITICAL)
raise GeoAlgorithmExecutionException(str(e) + self.tr('\nSee log for more details'), lines, e)
raise QgsProcessingException(str(e) + self.tr('\nSee log for more details'), lines, e)

def runPostExecutionScript(self, feedback):
scriptFile = ProcessingConfig.getSetting(
@@ -235,7 +235,7 @@ def resolveOutputs(self):
for out in self.outputs:
out.resolveValue(self)
except ValueError as e:
raise GeoAlgorithmExecutionException(str(e))
raise QgsProcessingException(str(e))

def setOutputCRS(self):
context = dataobjects.createContext()
@@ -319,7 +319,7 @@ def executeAlgorithm(alg, parameters, context=None, feedback=None, model=None):
it should be called using this method, since it performs
some additional operations.
Raises a GeoAlgorithmExecutionException in case anything goes
Raises a QgsProcessingException in case anything goes
wrong.
:param parameters:
"""

This file was deleted.

@@ -41,6 +41,7 @@
QgsMapLayer,
QgsProcessingProvider,
QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer)
@@ -54,7 +55,6 @@
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.gui.AlgorithmExecutor import execute
from processing.tools import dataobjects
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider # NOQA
#from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider # NOQA
@@ -140,7 +140,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
print('Error: Algorithm not found\n')
msg = Processing.tr('Error: Algorithm {0} not found\n').format(algOrName)
feedback.reportError(msg)
raise GeoAlgorithmExecutionException(msg)
raise QgsProcessingException(msg)

# check for any mandatory parameters which were not specified
for param in alg.parameterDefinitions():
@@ -150,7 +150,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
msg = Processing.tr('Error: Missing parameter value for parameter {0}.').format(param.name())
print('Error: Missing parameter value for parameter %s.' % param.name())
feedback.reportError(msg)
raise GeoAlgorithmExecutionException(msg)
raise QgsProcessingException(msg)

if context is None:
context = dataobjects.createContext(feedback)
@@ -161,7 +161,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
print('Unable to execute algorithm\n' + str(msg))
msg = Processing.tr('Unable to execute algorithm\n{0}').format(msg)
feedback.reportError(msg)
raise GeoAlgorithmExecutionException(msg)
raise QgsProcessingException(msg)

if not alg.validateInputCrs(parameters, context):
print('Warning: Not all input layers use the same CRS.\n' +
@@ -188,7 +188,7 @@ def runAlgorithm(algOrName, parameters, onFinish=None, feedback=None, context=No
else:
msg = Processing.tr("There were errors executing the algorithm.")
feedback.reportError(msg)
raise GeoAlgorithmExecutionException(msg)
raise QgsProcessingException(msg)

if isinstance(feedback, MessageBarProgress):
feedback.close()
@@ -37,9 +37,9 @@
QgsProcessingUtils,
QgsMessageLog,
QgsProperty,
QgsProcessingException,
QgsProcessingParameters,
QgsProcessingOutputLayerDefinition)
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.tools import dataobjects
from processing.tools.system import getTempFilename
@@ -61,7 +61,7 @@ def execute(alg, parameters, context=None, feedback=None):
try:
results, ok = alg.run(parameters, context, feedback)
return ok, results
except GeoAlgorithmExecutionException as e:
except QgsProcessingException as e:
QgsMessageLog.logMessage(str(sys.exc_info()[0]), 'Processing', QgsMessageLog.CRITICAL)
if feedback is not None:
feedback.reportError(e.msg)
@@ -51,10 +51,10 @@
from processing.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider # NOQA
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider # NOQA
#from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider # NOQA
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider # NOQA
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider # NOQA
#from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider # NOQA
#from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider # NOQA
from processing.script.ScriptAlgorithmProvider import ScriptAlgorithmProvider # NOQA
from processing.preconfigured.PreconfiguredAlgorithmProvider import PreconfiguredAlgorithmProvider # NOQA
#from processing.preconfigured.PreconfiguredAlgorithmProvider import PreconfiguredAlgorithmProvider # NOQA


from qgis.core import (QgsVectorLayer,
@@ -31,9 +31,9 @@
import shutil

from qgis.core import (QgsProcessingAlgorithm,
QgsProcessingFeedback)
QgsProcessingFeedback,
QgsProcessingException)
from qgis.testing import start_app, unittest
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.tools.dataobjects import createContext


@@ -55,7 +55,7 @@ def createInstance(self):
return TestAlg()

def processAlgorithm(self, parameters, context, feedback):
raise GeoAlgorithmExecutionException('Exception while processing')
raise QgsProcessingException('Exception while processing')
return {}


@@ -52,7 +52,6 @@
from processing.algs.gdal.GdalUtils import GdalUtils
from processing.tools.system import (getTempFilename,
removeInvalidChars)
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException

ALL_TYPES = [-1]

@@ -35,7 +35,7 @@
import numpy
from osgeo import gdal

from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from qgis.core import QgsProcessingException


RASTER_EXTENSION_MAP = None
@@ -96,7 +96,7 @@ def scanraster(layer, feedback):
elif bandtype == 'Float64':
values = struct.unpack('d' * band.XSize, scanline)
else:
raise GeoAlgorithmExecutionException('Raster format not supported')
raise QgsProcessingException('Raster format not supported')
for value in values:
if value == nodata:
value = None

0 comments on commit 5620854

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