Skip to content
Permalink
Browse files

More AlgExecutor logging

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@275 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Jun 30, 2012
1 parent 980ad22 commit 3c18386e751d3a4313275730f9e0f1bc21f61103
Showing with 35 additions and 27 deletions.
  1. +22 −25 src/sextante/gui/AlgorithmExecutor.py
  2. +13 −2 src/sextante/gui/ParametersDialog.py
@@ -8,7 +8,6 @@
class AlgorithmExecutor(QThread):
percentageChanged = pyqtSignal(int)
textChanged = pyqtSignal(QString)
#~ cancelled = pyqtSignal()
error = pyqtSignal()
iterated = pyqtSignal(int)
#started & finished inherited from QThread
@@ -51,10 +50,6 @@ def setPercentage(self, p):
def runalg(self):
try:
self.algorithm.execute(self.progress)
#===================================================================
# if self.algorithm.canceled:
# self.canceled.emit()
#===================================================================
except GeoAlgorithmExecutionException,e :
self.error.emit(e.msg)
except BaseException,e:
@@ -66,24 +61,26 @@ def runalg(self):
print "Error executing " + str(self)

def runalgIterating(self):
outputs = {}
#store output values to use them later as basenames for all outputs
for out in self.algorithm.outputs:
outputs[out.name] = out.value
i = 1
for f in self.filelist:
self.algorithm.setParameterValue(self.parameterToIterate, f)
try:
outputs = {}
#store output values to use them later as basenames for all outputs
for out in self.algorithm.outputs:
filename = outputs[out.name]
if filename:
filename = filename[:filename.rfind(".")] + "_" + str(i) + filename[filename.rfind("."):]
out.value = filename
self.progress.setText("Executing iteration " + str(i) + "/" + str(len(self.filelist)) + "...")
self.progress.setPercentage((i * 100) / len(self.filelist))
self.runalg()
#===================================================================
# if self.algorithm.canceled:
# return
#===================================================================
self.iterated.emit(i)
i += 1
outputs[out.name] = out.value
i = 1
for f in self.filelist:
self.algorithm.setParameterValue(self.parameterToIterate, f)
for out in self.algorithm.outputs:
filename = outputs[out.name]
if filename:
filename = filename[:filename.rfind(".")] + "_" + str(i) + filename[filename.rfind("."):]
out.value = filename
self.progress.setText("Executing iteration " + str(i) + "/" + str(len(self.filelist)) + "...")
self.progress.setPercentage((i * 100) / len(self.filelist))
self.runalg()
self.iterated.emit(i)
i += 1
except BaseException as e:
self.error.emit(str(e))
print "Error iterating " + str(e)
except:
print "Error iterating " + str(self)
@@ -191,7 +191,10 @@ def accept(self):
self.algEx.error.connect(self.error)
self.algEx.percentageChanged.connect(self.setPercentage)
self.algEx.textChanged.connect(self.setText)
self.algEx.iterated.connect(self.iterate)
self.algEx.start()
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s started" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
self.finish()
else:
@@ -220,6 +223,8 @@ def accept(self):
@pyqtSlot()
def finish(self):
self.dialog.executed = True
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s finished correctly" % self.alg.name)
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
@@ -232,8 +237,7 @@ def finish(self):
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)


@pyqtSlot()
@pyqtSlot(str)
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
@@ -247,8 +251,15 @@ def error(self, msg):
self.progress.setValue(0)
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)

@pyqtSlot(int)
def iterate(self, i):
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s iteration #%i completed" % (elf.alg.name, i))

@pyqtSlot()
def cancel(self):
SextanteLog.addToLog(SextanteLog.LOG_INFO,
"Algorithm %s canceled" % self.alg.name)
try:
self.algEx.finished.disconnect()
self.algEx.terminate()

0 comments on commit 3c18386

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