Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] [Processing] Catch some python errors in batch mode #2804

Merged
merged 2 commits into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions python/plugins/processing/gui/BatchPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)):
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,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:
Expand Down