Skip to content
Permalink
Browse files

Handle algorithm errors.

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@238 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Jun 11, 2012
1 parent f284e29 commit 377bbf89904bda86e43509512273b643ec542302
@@ -341,6 +341,11 @@ def runandload(name, *args):
def finish():
SextantePostprocessing.handleAlgorithmResults(alg)
QApplication.restoreOverrideCursor()
def error(msg):
QApplication.restoreOverrideCursor()
QMessageBox.critical(self, "Error", msg)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
algEx.error.connect(error)
algEx.finished.connect(finish)
algEx.start()

@@ -10,7 +10,7 @@
class AlgorithmExecutor(QThread):
percentageChanged = pyqtSignal(int)
textChanged = pyqtSignal(QString)
cancelled = pyqtSignal()
#~ cancelled = pyqtSignal()
error = pyqtSignal()
iterated = pyqtSignal(int)
#started & finished inherited from QThread
@@ -57,10 +57,10 @@ def runalg(self):
# if self.algorithm.canceled:
# self.canceled.emit()
#===================================================================
except GeoAlgorithmExecutionException, e :
self.error.emit()
except:
self.error.emit()
except GeoAlgorithmExecutionException as e :
self.error.emit(e.msg)
except BaseException as e:
self.error.emit(str(e))

def runalgIterating(self):
outputs = {}
@@ -95,7 +95,6 @@ def okPressed(self):
QMessageBox.critical(self, "Unable to execute batch process", "Wrong or missing parameter values")
self.algs = None
return
#~ row+=1 ??? - why?
self.algs.append(alg)

QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -126,8 +125,16 @@ def finish(self, i):
else:
self.nextAlg(i)

@pyqtSlot()
def error(self, msg):
QApplication.restoreOverrideCursor()
QMessageBox.critical(self, "Error", msg)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
self.close()

def nextAlg(self, i):
self.algEx = AlgorithmExecutor(self.algs[i]);
self.algEx.error.connect(self.error)
self.algEx.finished.connect(lambda: self.finish(i))
self.algEx.start()

@@ -181,6 +181,7 @@ def accept(self):
SextanteLog.addToLog(SextanteLog.LOG_ALGORITHM, command)
self.algEx = AlgorithmExecutor(self.alg)
self.algEx.finished.connect(self.finish)
self.algEx.error.connect(self.error)
self.algEx.percentageChanged.connect(self.setPercentage)
self.algEx.textChanged.connect(self.setText)
self.algEx.start()
@@ -204,16 +205,18 @@ def finish(self):
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)
SextantePostprocessing.handleAlgorithmResults(self.alg, not keepOpen)

#~ except GeoAlgorithmExecutionException, e :
#~ QApplication.restoreOverrideCursor()
#~ QMessageBox.critical(self, "Error",e.msg)
#~ SextanteLog.addToLog(SextanteLog.LOG_ERROR, e.msg)
#~ if not keepOpen:
#~ self.dialog.close()
#~ else:
#~ self.progressLabel.setText("")
#~ self.progress.setValue(0)
#~ self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
@pyqtSlot()
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
QMessageBox.critical(self, "Error", msg)
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
if not keepOpen:
self.dialog.close()
else:
self.progressLabel.setText("")
self.progress.setValue(0)
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)

@pyqtSlot()
def cancel(self):

0 comments on commit 377bbf8

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