Skip to content

Commit 9ceb1cc

Browse files
author
volayaf
committed
added optional logging for SAGA and GRASS
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@278 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 655bd11 commit 9ceb1cc

6 files changed

+20
-6
lines changed

src/sextante/grass/GrassAlgorithm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ def processAlgorithm(self, progress):
254254
loglines.append("GRASS execution commands")
255255
for line in commands:
256256
loglines.append(line)
257-
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
257+
if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_COMMANDS):
258+
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
258259
GrassUtils.executeGrass(commands, progress);
259260

260261

src/sextante/grass/GrassAlgorithmProvider.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from sextante.grass.GrassAlgorithm import GrassAlgorithm
99
from sextante.core.SextanteUtils import SextanteUtils
1010
from sextante.grass.DefineGrassRegionAction import DefineGrassRegionAction
11-
from sextante.grass.nviz import nviz
1211

1312
class GrassAlgorithmProvider(AlgorithmProvider):
1413

@@ -22,6 +21,8 @@ def initializeSettings(self):
2221
if SextanteUtils.isWindows():
2322
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
2423
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
24+
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
25+
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
2526
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_AUTO_REGION, "Use min covering region", True))
2627
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LATLON, "Coordinates are lat/lon", False))
2728
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMIN, "GRASS Region min x", 0))
@@ -44,6 +45,8 @@ def unload(self):
4445
SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMAX)
4546
SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_CELLSIZE)
4647
SextanteConfig.removeSetting(GrassUtils.GRASS_HELP_FOLDER)
48+
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
49+
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)
4750

4851
def createAlgsList(self):
4952
self.preloadedAlgs = []

src/sextante/grass/GrassUtils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class GrassUtils:
1919
GRASS_FOLDER = "GRASS_FOLDER"
2020
GRASS_HELP_FOLDER = "GRASS_HELP_FOLDER"
2121
GRASS_WIN_SHELL = "GRASS_WIN_SHELL"
22+
GRASS_LOG_COMMANDS = "GRASS_LOG_COMMANDS"
23+
GRASS_LOG_CONSOLE = "GRASS_LOG_CONSOLE"
2224

2325
@staticmethod
2426
def grassBatchJobFilename():
@@ -257,7 +259,8 @@ def executeGrass(commands, progress):
257259
pass
258260
else:
259261
loglines.append(line)
260-
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
262+
if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
263+
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
261264
shutil.rmtree(GrassUtils.grassMapsetFolder(), True)
262265

263266
@staticmethod

src/sextante/saga/SagaAlgorithm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ def processAlgorithm(self, progress):
279279
loglines.append("SAGA execution commands")
280280
for line in commands:
281281
loglines.append(line)
282-
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
282+
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
283+
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
283284
SagaUtils.executeSaga(progress);
284285

285286

src/sextante/saga/SagaAlgorithmProvider.py

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def initializeSettings(self):
2121
if SextanteUtils.isWindows():
2222
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_FOLDER, "SAGA folder", SagaUtils.sagaPath()))
2323
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_AUTO_RESAMPLING, "Use min covering grid system for resampling", True))
24+
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_COMMANDS, "Log execution commands", False))
25+
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_CONSOLE, "Log console output", False))
2426
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMIN, "Resampling region min x", 0))
2527
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMIN, "Resampling region min y", 0))
2628
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max x", 1000))
@@ -37,6 +39,8 @@ def unload(self):
3739
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMAX)
3840
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_YMAX)
3941
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE)
42+
SextanteConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
43+
SextanteConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)
4044

4145
def createAlgsList(self):
4246
self.preloadedAlgs = []

src/sextante/saga/SagaUtils.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
class SagaUtils:
99

10-
#SAGA_USE_SELECTED = "SAGA_USE_SELECTED"
10+
SAGA_LOG_COMMANDS = "SAGA_LOG_COMMANDS"
11+
SAGA_LOG_CONSOLE = "SAGA_LOG_CONSOLE"
1112
SAGA_AUTO_RESAMPLING = "SAGA_AUTO_RESAMPLING"
1213
SAGA_RESAMPLING_REGION_XMIN = "SAGA_RESAMPLING_REGION_XMIN"
1314
SAGA_RESAMPLING_REGION_YMIN = "SAGA_RESAMPLING_REGION_YMIN"
@@ -78,7 +79,8 @@ def executeSaga(progress):
7879
line = line.strip()
7980
if line!="/" and line!="-" and line !="\\" and line!="|":
8081
loglines.append(line)
81-
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
82+
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_CONSOLE):
83+
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
8284

8385

8486

0 commit comments

Comments
 (0)