Skip to content
Browse files
[sextante] added checking to GRASS algorithms
  • Loading branch information
volaya committed Apr 1, 2013
1 parent 4a560bb commit b5d667caf1909cb76cf2e2bda08f1b48fb88f613
@@ -84,6 +84,19 @@ def getName(self):

def getIcon(self):
return QIcon(os.path.dirname(__file__) + "/../images/grass.png")

def getPostProcessingErrorMessage(self, wrongLayers):
html = AlgorithmProvider.getPostProcessingErrorMessage(self, wrongLayers)
msg = GrassUtils.checkGrassIsInstalled(True)
html += ("<p>This algorithm requires GRASS to be run. A test to check if GRASS is correctly installed "
"and configured in your system has been performed, with the following result:</p><ul><i>")
if msg is None:
html += "GRASS seems to be correctly installed and configured</li></ul>"
html += msg + "</i></li></ul>"
html += '<p><a href= "">Click here</a> to know more about how to install and configure GRASS to be used with SEXTANTE</p>'

return html

def getSupportedOutputVectorLayerExtensions(self):
return ["shp"]
@@ -16,6 +16,8 @@
* *
from sextante.tests.TestData import points
import traceback

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -323,6 +325,34 @@ def getSessionLayers():
def addSessionLayers(exportedLayers):
GrassUtils.sessionLayers = dict(GrassUtils.sessionLayers.items() + exportedLayers.items())

def checkGrassIsInstalled(ignoreRegistrySettings=False):
if SextanteUtils.isWindows():
path = GrassUtils.grassPath()
if path == "":
return "GRASS folder is not configured.\nPlease configure it before running SAGA algorithms."
cmdpath = os.path.join(path, "bin\r.out.exe")
if not os.path.exists(cmdpath):
return ("The specified GRASS folder does not contain a valid set of GRASS modules.\n"
+ "Please, go to the SEXTANTE settings dialog, and check that the GRASS\n"
+ "folder is correctly configured")

if not ignoreRegistrySettings:
GRASS_INSTALLED = "/SextanteQGIS/GrassInstalled"
settings = QSettings()
if settings.contains(GRASS_INSTALLED):

from sextante.core.Sextante import runalg
result = runalg("grass:v.voronoi", points(),False,False,"270778.60198,270855.745301,4458921.97814,4458983.8488",-1,0.0001,None)
if not os.path.exists(result['output']):
return "It seems that GRASS is not correctly installed and configured in your system.\nPlease install it before running GRASS algorithms."
s = traceback.format_exc()
return "Error while checking GRASS installation. GRASS might not be correctly configured.\n" + s;

settings.setValue(GRASS_INSTALLED, True)

0 comments on commit b5d667c

Please sign in to comment.