Skip to content
Permalink
Browse files

fixed #6015

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@308 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com
volayaf@gmail.com committed Jul 22, 2012
1 parent 6ddcf98 commit 7eada52846fabbc1521250d5661260d35db92c36
Showing with 19 additions and 14 deletions.
  1. +2 −3 src/sextante/grass/GrassAlgorithmProvider.py
  2. +17 −11 src/sextante/grass/GrassUtils.py
@@ -18,7 +18,7 @@ def __init__(self):

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
if SextanteUtils.isWindows():
if SextanteUtils.isWindows() or SextanteUtils.isMac():
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))
@@ -34,7 +34,7 @@ def initializeSettings(self):

def unload(self):
AlgorithmProvider.unload(self)
if SextanteUtils.isWindows():
if SextanteUtils.isWindows() or SextanteUtils.isMac():
SextanteConfig.removeSetting(GrassUtils.GRASS_FOLDER)
SextanteConfig.removeSetting(GrassUtils.GRASS_WIN_SHELL)
SextanteConfig.removeSetting(GrassUtils.GRASS_AUTO_REGION)
@@ -62,7 +62,6 @@ def createAlgsList(self):
except Exception,e:
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open GRASS algorithm: " + descriptionFile)
#self.preloadedAlgs.append(nviz())
#self.createDescriptionFiles()

def _loadAlgorithms(self):
self.algs = self.preloadedAlgs
@@ -40,20 +40,23 @@ def grassScriptFilename():

@staticmethod
def grassPath():
if not SextanteUtils.isWindows():
if not SextanteUtils.isWindows() and not SextanteUtils.isMac():
return ""

folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
if folder == None:
folder = plugin_installer.__file__
idx = folder.find('qgis')
folder = folder[:idx] + "grass"
if not os.path.isdir(folder):
return ""
for subfolder in os.listdir(folder):
if subfolder.startswith("grass"):
folder = folder + os.sep + subfolder
break
if SextanteUtils.isWindows():
folder = plugin_installer.__file__
idx = folder.find('qgis')
folder = folder[:idx] + "grass"
if not os.path.isdir(folder):
return ""
for subfolder in os.listdir(folder):
if subfolder.startswith("grass"):
folder = folder + os.sep + subfolder
break
else:
return "/Applications/GRASS-6.4.app/Contents/MacOS"

return folder

@@ -247,7 +250,10 @@ def executeGrass(commands, progress):
os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
if SextanteUtils.isMac():
command = GrassUtils.grassPath() + os.sep + "grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
else:
command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"
loglines = []
loglines.append("GRASS execution console output")
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout

0 comments on commit 7eada52

Please sign in to comment.
You can’t perform that action at this time.