mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
fixed #6015
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@308 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
This commit is contained in:
parent
6ddcf9859a
commit
7eada52846
@ -18,7 +18,7 @@ class GrassAlgorithmProvider(AlgorithmProvider):
|
||||
|
||||
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 @@ class GrassAlgorithmProvider(AlgorithmProvider):
|
||||
|
||||
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 @@ class GrassAlgorithmProvider(AlgorithmProvider):
|
||||
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 @@ class GrassUtils:
|
||||
|
||||
@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 @@ class GrassUtils:
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user