Skip to content
Permalink
Browse files

Merge pull request #2804 from Gustry/processing-error

[Bugfix] [Processing] Catch some python errors in batch mode
  • Loading branch information
volaya committed Mar 3, 2016
2 parents 193fedf + 3039f13 commit b3b41015a1ba41aaa9335ceb28c42732ea217067
Showing with 35 additions and 24 deletions.
  1. +32 −23 python/plugins/processing/gui/BatchPanel.py
  2. +3 −1 python/plugins/processing/modeler/ModelerAlgorithm.py
@@ -30,7 +30,7 @@

from PyQt4 import uic
from PyQt4.QtGui import (QWidget, QIcon, QTableWidgetItem, QComboBox, QLineEdit,
QHeaderView, QFileDialog)
QHeaderView, QFileDialog, QMessageBox)

from qgis.core import QgsApplication

@@ -184,30 +184,39 @@ def load(self):
if filename:
with open(filename) as f:
values = json.load(f)
else:
# If the user clicked on the cancel button.
return

self.tblParameters.setRowCount(0)
for row, alg in enumerate(values):
self.addRow()
params = alg[self.PARAMETERS]
outputs = alg[self.OUTPUTS]
column = 0
for param in self.alg.parameters:
if param.hidden:
continue
widget = self.tblParameters.cellWidget(row, column)
if param.name in params:
value = params[param.name]
self.setValueInWidget(widget, value)
column += 1

for out in self.alg.outputs:
if out.hidden:
continue
widget = self.tblParameters.cellWidget(row, column)
if out.name in outputs:
value = outputs[out.name]
self.setValueInWidget(widget, value)
column += 1
try:
for row, alg in enumerate(values):
self.addRow()
params = alg[self.PARAMETERS]
outputs = alg[self.OUTPUTS]
column = 0
for param in self.alg.parameters:
if param.hidden:
continue
widget = self.tblParameters.cellWidget(row, column)
if param.name in params:
value = params[param.name]
self.setValueInWidget(widget, value)
column += 1

for out in self.alg.outputs:
if out.hidden:
continue
widget = self.tblParameters.cellWidget(row, column)
if out.name in outputs:
value = outputs[out.name]
self.setValueInWidget(widget, value)
column += 1
except TypeError:
QMessageBox.critical(
self,
self.tr('Error'),
self.tr('An error occured while reading your file.'))

def setValueInWidget(self, widget, value):
if isinstance(widget, (BatchInputSelectionPanel, QLineEdit, FileSelectionPanel)):
@@ -397,7 +397,9 @@ def prepareAlgorithm(self, alg):
if not param.setValue(value) and not isinstance(param,
ParameterDataObject):
raise GeoAlgorithmExecutionException(
self.tr('Wrong value: %s', 'ModelerAlgorithm') % value)
self.tr('Wrong value %s for %s %s', 'ModelerAlgorithm')
% (value, param.__class__.__name__, param.name))

for out in algInstance.outputs:
if not out.hidden:
if out.name in alg.outputs:

0 comments on commit b3b4101

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