mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Some formatting in parameters dialog log. Plus "debug" info for modeler algorithms.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@336 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
This commit is contained in:
parent
cb99d37fdc
commit
083f3e47e5
@ -206,8 +206,10 @@ class AlgorithmExecutionDialog(QtGui.QDialog):
|
||||
self.algEx.textChanged.connect(self.setText)
|
||||
self.algEx.iterated.connect(self.iterate)
|
||||
self.algEx.infoSet.connect(self.setInfo)
|
||||
self.algEx.commandSet.connect(self.setCommand)
|
||||
self.algEx.debugInfoSet.connect(self.setDebugInfo)
|
||||
self.algEx.start()
|
||||
self.setInfo("Algorithm %s started" % self.alg.name)
|
||||
self.setInfo("<b>Algorithm %s started</b>" % self.alg.name)
|
||||
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
|
||||
self.tabWidget.setCurrentIndex(1) # log tab
|
||||
else:
|
||||
@ -268,11 +270,11 @@ class AlgorithmExecutionDialog(QtGui.QDialog):
|
||||
|
||||
@pyqtSlot(int)
|
||||
def iterate(self, i):
|
||||
self.setInfo("Algorithm %s iteration #%i completed" % (self.alg.name, i))
|
||||
self.setInfo("<b>Algorithm %s iteration #%i completed</b>" % (self.alg.name, i))
|
||||
|
||||
@pyqtSlot()
|
||||
def cancel(self):
|
||||
self.setInfo("Algorithm %s canceled" % self.alg.name)
|
||||
self.setInfo("<b>Algorithm %s canceled</b>" % self.alg.name)
|
||||
try:
|
||||
self.algEx.finished.disconnect()
|
||||
self.algEx.terminate()
|
||||
@ -284,14 +286,23 @@ class AlgorithmExecutionDialog(QtGui.QDialog):
|
||||
pass
|
||||
|
||||
@pyqtSlot(str)
|
||||
@pyqtSlot(str, bool)
|
||||
def setInfo(self, msg, error = False):
|
||||
if error:
|
||||
#SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
|
||||
self.logText.append('<b>' + msg + '</b>')
|
||||
self.logText.append('<span style="color:red">' + msg + '</span>')
|
||||
else:
|
||||
#SextanteLog.addToLog(SextanteLog.LOG_INFO, msg)
|
||||
self.logText.append(msg)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setCommand(self, cmd):
|
||||
self.setInfo('<tt>' + cmd + '<tt>')
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setDebugInfo(self, msg):
|
||||
self.setInfo('<span style="color:blue">' + msg + '</span>')
|
||||
|
||||
def setPercentage(self, i):
|
||||
if self.progress.maximum() == 0:
|
||||
self.progress.setMaximum(100)
|
||||
|
@ -12,6 +12,8 @@ class AlgorithmExecutor(QThread):
|
||||
error = pyqtSignal(str)
|
||||
iterated = pyqtSignal(int)
|
||||
infoSet = pyqtSignal(str)
|
||||
commandSet = pyqtSignal(str)
|
||||
debugInfoSet = pyqtSignal(str)
|
||||
#started & finished inherited from QThread
|
||||
|
||||
def __init__(self, alg, iterParam = None, parent = None):
|
||||
@ -28,6 +30,10 @@ class AlgorithmExecutor(QThread):
|
||||
self.algorithmExecutor.percentageChanged.emit(p)
|
||||
def setInfo(self, info):
|
||||
self.algorithmExecutor.infoSet.emit(info)
|
||||
def setCommand(self, cmd):
|
||||
self.algorithmExecutor.commandSet.emit(cmd)
|
||||
def setDebugInfo(self, info):
|
||||
self.algorithmExecutor.debugInfoSet.emit(info)
|
||||
self.progress = Progress(self)
|
||||
if self.parameterToIterate:
|
||||
self.run = self.runalgIterating
|
||||
|
@ -77,3 +77,9 @@ class SilentProgress():
|
||||
|
||||
def setInfo(self, _):
|
||||
pass
|
||||
|
||||
def setCommand(self, _):
|
||||
pass
|
||||
|
||||
def setDebugInfo(self, _):
|
||||
pass
|
||||
|
@ -370,6 +370,7 @@ class ModelerAlgorithm(GeoAlgorithm):
|
||||
if canExecute:
|
||||
try:
|
||||
alg = alg.getCopy()
|
||||
progress.setDebugInfo("Prepare algorithm %i: %s" % (iAlg, alg.name))
|
||||
self.prepareAlgorithm(alg, iAlg)
|
||||
progress.setText("Running " + alg.name + " [" + str(iAlg+1) + "/"
|
||||
+ str(len(self.algs) - len(self.deactivated)) +"]")
|
||||
@ -379,9 +380,14 @@ class ModelerAlgorithm(GeoAlgorithm):
|
||||
outputs[out.name] = out.value
|
||||
self.producedOutputs[iAlg] = outputs
|
||||
executed.append(iAlg)
|
||||
progress.setDebugInfo("OK. %i outputs" % len(outputs))
|
||||
except GeoAlgorithmExecutionException, e :
|
||||
progress.setDebugInfo("Failed")
|
||||
raise GeoAlgorithmExecutionException("Error executing algorithm " + str(iAlg) + "\n" + e.msg)
|
||||
else:
|
||||
progress.setDebugInfo("Algorithm %s deactivated (or already executed)" % alg.name)
|
||||
iAlg += 1
|
||||
progress.setDebugInfo("Model processed ok. Executed %i algorithms total" % iAlg)
|
||||
|
||||
def getOutputType(self, i, outname):
|
||||
for out in self.algs[i].outputs:
|
||||
@ -509,4 +515,4 @@ class AlgorithmAndParameter():
|
||||
return self.paramName
|
||||
|
||||
def __str__(self):
|
||||
return str(self.alg) + "|" + str(self.param)
|
||||
return str(self.alg) + "|" + str(self.param)
|
||||
|
@ -142,7 +142,7 @@ class OTBAlgorithm(GeoAlgorithm):
|
||||
"-sizex", str(sizeX),
|
||||
"-sizey", str(sizeY)]
|
||||
SextanteLog.addToLog(SextanteLog.LOG_INFO, helperCommands)
|
||||
progress.setInfo(helperCommands)
|
||||
progress.setCommand(helperCommands)
|
||||
OTBUtils.executeOtb(helperCommands, progress)
|
||||
|
||||
if self.roiRasters:
|
||||
@ -155,6 +155,7 @@ class OTBAlgorithm(GeoAlgorithm):
|
||||
"-io.out", roiFile,
|
||||
"-elev.dem.path", OTBUtils.otbSRTMPath()]
|
||||
SextanteLog.addToLog(SextanteLog.LOG_INFO, helperCommands)
|
||||
progress.setCommand(helperCommands)
|
||||
OTBUtils.executeOtb(helperCommands, progress)
|
||||
|
||||
loglines = []
|
||||
@ -162,6 +163,6 @@ class OTBAlgorithm(GeoAlgorithm):
|
||||
for line in commands:
|
||||
loglines.append(line)
|
||||
|
||||
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
|
||||
progress.setCommand(loglines)
|
||||
OTBUtils.executeOtb(commands, progress)
|
||||
|
||||
|
||||
|
@ -278,7 +278,7 @@ class SagaAlgorithm(GeoAlgorithm):
|
||||
loglines = []
|
||||
loglines.append("SAGA execution commands")
|
||||
for line in commands:
|
||||
progress.setInfo(line)
|
||||
progress.setCommand(line)
|
||||
loglines.append(line)
|
||||
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
|
||||
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
|
||||
|
Loading…
x
Reference in New Issue
Block a user