Skip to content

Commit 083f3e4

Browse files
author
cpolymeris@gmail.com
committedAug 6, 2012
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
1 parent cb99d37 commit 083f3e4

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed
 

‎src/sextante/gui/AlgorithmExecutionDialog.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ def accept(self):
206206
self.algEx.textChanged.connect(self.setText)
207207
self.algEx.iterated.connect(self.iterate)
208208
self.algEx.infoSet.connect(self.setInfo)
209+
self.algEx.commandSet.connect(self.setCommand)
210+
self.algEx.debugInfoSet.connect(self.setDebugInfo)
209211
self.algEx.start()
210-
self.setInfo("Algorithm %s started" % self.alg.name)
212+
self.setInfo("<b>Algorithm %s started</b>" % self.alg.name)
211213
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
212214
self.tabWidget.setCurrentIndex(1) # log tab
213215
else:
@@ -268,11 +270,11 @@ def error(self, msg):
268270

269271
@pyqtSlot(int)
270272
def iterate(self, i):
271-
self.setInfo("Algorithm %s iteration #%i completed" % (self.alg.name, i))
273+
self.setInfo("<b>Algorithm %s iteration #%i completed</b>" % (self.alg.name, i))
272274

273275
@pyqtSlot()
274276
def cancel(self):
275-
self.setInfo("Algorithm %s canceled" % self.alg.name)
277+
self.setInfo("<b>Algorithm %s canceled</b>" % self.alg.name)
276278
try:
277279
self.algEx.finished.disconnect()
278280
self.algEx.terminate()
@@ -284,14 +286,23 @@ def cancel(self):
284286
pass
285287

286288
@pyqtSlot(str)
289+
@pyqtSlot(str, bool)
287290
def setInfo(self, msg, error = False):
288291
if error:
289292
#SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
290-
self.logText.append('<b>' + msg + '</b>')
293+
self.logText.append('<span style="color:red">' + msg + '</span>')
291294
else:
292295
#SextanteLog.addToLog(SextanteLog.LOG_INFO, msg)
293296
self.logText.append(msg)
294297

298+
@pyqtSlot(str)
299+
def setCommand(self, cmd):
300+
self.setInfo('<tt>' + cmd + '<tt>')
301+
302+
@pyqtSlot(str)
303+
def setDebugInfo(self, msg):
304+
self.setInfo('<span style="color:blue">' + msg + '</span>')
305+
295306
def setPercentage(self, i):
296307
if self.progress.maximum() == 0:
297308
self.progress.setMaximum(100)

‎src/sextante/gui/AlgorithmExecutor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class AlgorithmExecutor(QThread):
1212
error = pyqtSignal(str)
1313
iterated = pyqtSignal(int)
1414
infoSet = pyqtSignal(str)
15+
commandSet = pyqtSignal(str)
16+
debugInfoSet = pyqtSignal(str)
1517
#started & finished inherited from QThread
1618

1719
def __init__(self, alg, iterParam = None, parent = None):
@@ -28,6 +30,10 @@ def setPercentage(self, p):
2830
self.algorithmExecutor.percentageChanged.emit(p)
2931
def setInfo(self, info):
3032
self.algorithmExecutor.infoSet.emit(info)
33+
def setCommand(self, cmd):
34+
self.algorithmExecutor.commandSet.emit(cmd)
35+
def setDebugInfo(self, info):
36+
self.algorithmExecutor.debugInfoSet.emit(info)
3137
self.progress = Progress(self)
3238
if self.parameterToIterate:
3339
self.run = self.runalgIterating

‎src/sextante/gui/UnthreadedAlgorithmExecutor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ def setPercentage(self, i):
7777

7878
def setInfo(self, _):
7979
pass
80+
81+
def setCommand(self, _):
82+
pass
83+
84+
def setDebugInfo(self, _):
85+
pass

‎src/sextante/modeler/ModelerAlgorithm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def processAlgorithm(self, progress):
370370
if canExecute:
371371
try:
372372
alg = alg.getCopy()
373+
progress.setDebugInfo("Prepare algorithm %i: %s" % (iAlg, alg.name))
373374
self.prepareAlgorithm(alg, iAlg)
374375
progress.setText("Running " + alg.name + " [" + str(iAlg+1) + "/"
375376
+ str(len(self.algs) - len(self.deactivated)) +"]")
@@ -379,9 +380,14 @@ def processAlgorithm(self, progress):
379380
outputs[out.name] = out.value
380381
self.producedOutputs[iAlg] = outputs
381382
executed.append(iAlg)
383+
progress.setDebugInfo("OK. %i outputs" % len(outputs))
382384
except GeoAlgorithmExecutionException, e :
385+
progress.setDebugInfo("Failed")
383386
raise GeoAlgorithmExecutionException("Error executing algorithm " + str(iAlg) + "\n" + e.msg)
387+
else:
388+
progress.setDebugInfo("Algorithm %s deactivated (or already executed)" % alg.name)
384389
iAlg += 1
390+
progress.setDebugInfo("Model processed ok. Executed %i algorithms total" % iAlg)
385391

386392
def getOutputType(self, i, outname):
387393
for out in self.algs[i].outputs:
@@ -509,4 +515,4 @@ def name(self):
509515
return self.paramName
510516

511517
def __str__(self):
512-
return str(self.alg) + "|" + str(self.param)
518+
return str(self.alg) + "|" + str(self.param)

‎src/sextante/otb/OTBAlgorithm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def processAlgorithm(self, progress):
142142
"-sizex", str(sizeX),
143143
"-sizey", str(sizeY)]
144144
SextanteLog.addToLog(SextanteLog.LOG_INFO, helperCommands)
145-
progress.setInfo(helperCommands)
145+
progress.setCommand(helperCommands)
146146
OTBUtils.executeOtb(helperCommands, progress)
147147

148148
if self.roiRasters:
@@ -155,13 +155,14 @@ def processAlgorithm(self, progress):
155155
"-io.out", roiFile,
156156
"-elev.dem.path", OTBUtils.otbSRTMPath()]
157157
SextanteLog.addToLog(SextanteLog.LOG_INFO, helperCommands)
158+
progress.setCommand(helperCommands)
158159
OTBUtils.executeOtb(helperCommands, progress)
159160

160161
loglines = []
161162
loglines.append("OTB execution command")
162163
for line in commands:
163164
loglines.append(line)
164165

166+
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
167+
progress.setCommand(loglines)
165168
OTBUtils.executeOtb(commands, progress)
166-
167-

‎src/sextante/saga/SagaAlgorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def processAlgorithm(self, progress):
278278
loglines = []
279279
loglines.append("SAGA execution commands")
280280
for line in commands:
281-
progress.setInfo(line)
281+
progress.setCommand(line)
282282
loglines.append(line)
283283
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
284284
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)

0 commit comments

Comments
 (0)
Please sign in to comment.