Skip to content
Permalink
Browse files

catch some python error in batch processing

  • Loading branch information
Gustry authored and alexbruy committed Mar 7, 2016
1 parent 66b66c5 commit bceea09f5eddab48153f352ca8ce39c17dfcebae
Showing with 32 additions and 23 deletions.
  1. +32 −23 python/plugins/processing/gui/BatchPanel.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

@@ -180,30 +180,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)):

0 comments on commit bceea09

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