Skip to content

Commit

Permalink
added optional logging for SAGA and GRASS
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@278 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Jul 1, 2012
1 parent 655bd11 commit 9ceb1cc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/sextante/grass/GrassAlgorithm.py
Expand Up @@ -254,7 +254,8 @@ def processAlgorithm(self, progress):
loglines.append("GRASS execution commands")
for line in commands:
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_COMMANDS):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
GrassUtils.executeGrass(commands, progress);


Expand Down
5 changes: 4 additions & 1 deletion src/sextante/grass/GrassAlgorithmProvider.py
Expand Up @@ -8,7 +8,6 @@
from sextante.grass.GrassAlgorithm import GrassAlgorithm
from sextante.core.SextanteUtils import SextanteUtils
from sextante.grass.DefineGrassRegionAction import DefineGrassRegionAction
from sextante.grass.nviz import nviz

class GrassAlgorithmProvider(AlgorithmProvider):

Expand All @@ -22,6 +21,8 @@ def initializeSettings(self):
if SextanteUtils.isWindows():
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_FOLDER, "GRASS folder", GrassUtils.grassPath()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_WIN_SHELL, "Msys folder", GrassUtils.grassWinShell()))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_COMMANDS, "Log execution commands", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LOG_CONSOLE, "Log console output", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_AUTO_REGION, "Use min covering region", True))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_LATLON, "Coordinates are lat/lon", False))
SextanteConfig.addSetting(Setting(self.getDescription(), GrassUtils.GRASS_REGION_XMIN, "GRASS Region min x", 0))
Expand All @@ -44,6 +45,8 @@ def unload(self):
SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_YMAX)
SextanteConfig.removeSetting(GrassUtils.GRASS_REGION_CELLSIZE)
SextanteConfig.removeSetting(GrassUtils.GRASS_HELP_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS)
SextanteConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE)

def createAlgsList(self):
self.preloadedAlgs = []
Expand Down
5 changes: 4 additions & 1 deletion src/sextante/grass/GrassUtils.py
Expand Up @@ -19,6 +19,8 @@ class GrassUtils:
GRASS_FOLDER = "GRASS_FOLDER"
GRASS_HELP_FOLDER = "GRASS_HELP_FOLDER"
GRASS_WIN_SHELL = "GRASS_WIN_SHELL"
GRASS_LOG_COMMANDS = "GRASS_LOG_COMMANDS"
GRASS_LOG_CONSOLE = "GRASS_LOG_CONSOLE"

@staticmethod
def grassBatchJobFilename():
Expand Down Expand Up @@ -257,7 +259,8 @@ def executeGrass(commands, progress):
pass
else:
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
if SextanteConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
shutil.rmtree(GrassUtils.grassMapsetFolder(), True)

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion src/sextante/saga/SagaAlgorithm.py
Expand Up @@ -279,7 +279,8 @@ def processAlgorithm(self, progress):
loglines.append("SAGA execution commands")
for line in commands:
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_COMMANDS):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
SagaUtils.executeSaga(progress);


Expand Down
4 changes: 4 additions & 0 deletions src/sextante/saga/SagaAlgorithmProvider.py
Expand Up @@ -21,6 +21,8 @@ def initializeSettings(self):
if SextanteUtils.isWindows():
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_FOLDER, "SAGA folder", SagaUtils.sagaPath()))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_AUTO_RESAMPLING, "Use min covering grid system for resampling", True))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_COMMANDS, "Log execution commands", False))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_LOG_CONSOLE, "Log console output", False))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMIN, "Resampling region min x", 0))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_YMIN, "Resampling region min y", 0))
SextanteConfig.addSetting(Setting(self.getDescription(), SagaUtils.SAGA_RESAMPLING_REGION_XMAX, "Resampling region max x", 1000))
Expand All @@ -37,6 +39,8 @@ def unload(self):
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_XMAX)
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_YMAX)
SextanteConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE)
SextanteConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
SextanteConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)

def createAlgsList(self):
self.preloadedAlgs = []
Expand Down
6 changes: 4 additions & 2 deletions src/sextante/saga/SagaUtils.py
Expand Up @@ -7,7 +7,8 @@

class SagaUtils:

#SAGA_USE_SELECTED = "SAGA_USE_SELECTED"
SAGA_LOG_COMMANDS = "SAGA_LOG_COMMANDS"
SAGA_LOG_CONSOLE = "SAGA_LOG_CONSOLE"
SAGA_AUTO_RESAMPLING = "SAGA_AUTO_RESAMPLING"
SAGA_RESAMPLING_REGION_XMIN = "SAGA_RESAMPLING_REGION_XMIN"
SAGA_RESAMPLING_REGION_YMIN = "SAGA_RESAMPLING_REGION_YMIN"
Expand Down Expand Up @@ -78,7 +79,8 @@ def executeSaga(progress):
line = line.strip()
if line!="/" and line!="-" and line !="\\" and line!="|":
loglines.append(line)
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)
if SextanteConfig.getSetting(SagaUtils.SAGA_LOG_CONSOLE):
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines)



Expand Down

0 comments on commit 9ceb1cc

Please sign in to comment.