Skip to content
Permalink
Browse files

[processing] added check to ensure input layers are valid

  • Loading branch information
volaya committed Jun 23, 2015
1 parent 247c2f0 commit 83f3a5893cbb63f7bfd01649a9071fd297cbd46d
@@ -246,6 +246,21 @@ def execute(self, progress=None, model=None):
raise GeoAlgorithmExecutionException(
str(e) + self.tr('\nSee log for more details'))

def _checkParameterValuesBeforeExecuting(self):
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector,
ParameterMultipleInput)):
if param.value:
if isinstance(param, ParameterMultipleInput):
inputlayers = param.value.split(';')
else:
inputlayers = [param.value]
for inputlayer in inputlayers:
obj = dataobjects.getObjectFromUri(inputlayer)
if obj is None:
return "Wrong parameter value: " + param.value
return self.checkParameterValuesBeforeExecuting()

def runPostExecutionScript(self, progress):
scriptFile = ProcessingConfig.getSetting(
ProcessingConfig.POST_EXECUTION_SCRIPT)
@@ -327,7 +327,7 @@ def runAlgorithm(algOrName, onFinish, *args):
return
i = i + 1

msg = alg.checkParameterValuesBeforeExecuting()
msg = alg._checkParameterValuesBeforeExecuting()
if msg:
print 'Unable to execute algorithm\n' + msg
return
@@ -156,7 +156,7 @@ def accept(self):
QMessageBox.No)
if reply == QMessageBox.No:
return
msg = self.alg.checkParameterValuesBeforeExecuting()
msg = self.alg._checkParameterValuesBeforeExecuting()
if msg:
QMessageBox.warning(
self, self.tr('Unable to execute algorithm'), msg)

0 comments on commit 83f3a58

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