Skip to content

Commit

Permalink
[processing] added check to ensure input layers are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jun 23, 2015
1 parent 247c2f0 commit 83f3a58
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/Processing.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -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)
Expand Down

0 comments on commit 83f3a58

Please sign in to comment.