Skip to content

Commit

Permalink
[processing] remove GeoAlgorithmExecutionException
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jul 13, 2017
1 parent 97a5a3d commit 5620854
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 72 deletions.
16 changes: 8 additions & 8 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
"""
Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
"""
Expand Down
48 changes: 0 additions & 48 deletions python/plugins/processing/core/GeoAlgorithmExecutionException.py

This file was deleted.

10 changes: 5 additions & 5 deletions python/plugins/processing/core/Processing.py
Expand Up @@ -41,6 +41,7 @@
QgsMapLayer,
QgsProcessingProvider,
QgsProcessingAlgorithm,
QgsProcessingException,
QgsProcessingParameterDefinition,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer)
Expand All @@ -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
Expand Down Expand Up @@ -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():
Expand All @@ -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)
Expand All @@ -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' +
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/AlgorithmExecutor.py
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/tests/QgisAlgorithmsTest.py
Expand Up @@ -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


Expand All @@ -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 {}


Expand Down
1 change: 0 additions & 1 deletion python/plugins/processing/tools/dataobjects.py
Expand Up @@ -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]

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/tools/raster.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5620854

Please sign in to comment.