Skip to content
Permalink
Browse files

Log only for threaded algorithm execution

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@332 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Aug 3, 2012
1 parent f2c9b03 commit e46b466222a41f590cacf69dcfa487954906f5f4
Showing with 15 additions and 10 deletions.
  1. +11 −9 src/sextante/gui/AlgorithmExecutionDialog.py
  2. +4 −1 src/sextante/gui/UnthreadedAlgorithmExecutor.py
@@ -69,7 +69,8 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
self.tabWidget.addTab(self.logText, "Log")
if SextanteConfig.getSetting(SextanteConfig.USE_THREADS):
self.tabWidget.addTab(self.logText, "Log")
self.webView = QtWebKit.QWebView()
cssUrl = QtCore.QUrl(os.path.join(os.path.dirname(__file__), "help", "help.css"))
self.webView.settings().setUserStyleSheetUrl(cssUrl)
@@ -199,10 +200,11 @@ def accept(self):
self.algEx.percentageChanged.connect(self.setPercentage)
self.algEx.textChanged.connect(self.setText)
self.algEx.iterated.connect(self.iterate)
self.algEx.infoSet.connect(self.log)
self.algEx.infoSet.connect(self.setInfo)
self.algEx.start()
self.log("Algorithm %s started" % self.alg.name)
self.setInfo("Algorithm %s started" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
self.tabWidget.setCurrentIndex(1) # log tab
self.finish()
else:
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
@@ -233,7 +235,7 @@ def accept(self):
@pyqtSlot()
def finish(self):
self.executed = True
self.log("Algorithm %s finished correctly" % self.alg.name)
self.setInfo("Algorithm %s finished correctly" % self.alg.name)
QApplication.restoreOverrideCursor()
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
@@ -250,7 +252,7 @@ def finish(self):
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
self.log(msg, True)
self.setInfo(msg, True)
QMessageBox.critical(self, "Error", msg)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
@@ -262,11 +264,11 @@ def error(self, msg):

@pyqtSlot(int)
def iterate(self, i):
self.log("Algorithm %s iteration #%i completed" % (self.alg.name, i))
self.setInfo("Algorithm %s iteration #%i completed" % (self.alg.name, i))

@pyqtSlot()
def cancel(self):
self.log("Algorithm %s canceled" % self.alg.name)
self.setInfo("Algorithm %s canceled" % self.alg.name)
try:
self.algEx.finished.disconnect()
self.algEx.terminate()
@@ -276,7 +278,7 @@ def cancel(self):
pass

@pyqtSlot(str)
def log(self, msg, error = False):
def setInfo(self, msg, error = False):
if error:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
self.logText.append('<b>' + msg + '</b>')
@@ -291,4 +293,4 @@ def setPercentage(self, i):

def setText(self, text):
self.progressLabel.setText(text)
self.log(text, False)
self.setInfo(text, False)
@@ -73,4 +73,7 @@ def setText(self, text):
pass

def setPercentage(self, i):
pass
pass

def setInfo(self, _):
pass

0 comments on commit e46b466

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