Skip to content

Commit

Permalink
fix autodetect of saga & otb on OS X, also detect bundled grass, saga…
Browse files Browse the repository at this point in the history
… & otb
  • Loading branch information
kyngchaos committed Apr 7, 2013
1 parent 5edc9df commit baedeb2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
7 changes: 5 additions & 2 deletions python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
__revision__ = '$Format:%H$'

import os
from qgis.core import QgsApplication
from PyQt4.QtCore import *
import traceback
import subprocess
Expand Down Expand Up @@ -87,15 +88,17 @@ def grassPath():
folder = folder + os.sep + subfolder
break
else:
return "/Applications/GRASS-6.4.app/Contents/MacOS"
folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
if not os.path.isdir(folder):
folder = "/Applications/GRASS-6.4.app/Contents/MacOS"

return folder

@staticmethod
def grassHelpPath():
folder = SextanteConfig.getSetting(GrassUtils.GRASS_HELP_FOLDER)
if folder == None or folder == "":
if SextanteUtils.isWindows():
if SextanteUtils.isWindows() or SextanteUtils.isMac():
testfolders = [os.path.join(GrassUtils.grassPath(), "docs", "html")]
else:
testfolders = ['/usr/share/doc/grass-doc/html']
Expand Down
30 changes: 25 additions & 5 deletions python/plugins/sextante/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
__revision__ = '$Format:%H$'

import os
from qgis.core import QgsApplication
import subprocess
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.SextanteLog import SextanteLog
Expand All @@ -42,8 +43,18 @@ def otbPath():
if folder == None:
folder = ""

if os.path.exists("/usr/bin/otbcli"):
folder = "/usr/bin"
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "otbcli")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
folder = testfolder
else:
testfolder = "/usr/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
folder = testfolder
return folder

@staticmethod
Expand All @@ -52,9 +63,18 @@ def otbLibPath():
if folder == None:
folder =""

linuxstandardpath = "/usr/lib/otb/applications"
if os.path.exists(linuxstandardpath):
folder = linuxstandardpath
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "lib/otb/applications")
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/local/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
return folder

@staticmethod
Expand Down
13 changes: 12 additions & 1 deletion python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def sagaPath():
if folder == None:
folder =""

if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
else:
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
folder = testfolder
return folder

@staticmethod
Expand All @@ -76,8 +84,11 @@ def createSagaBatchJobFileFromSagaCommands(commands):
fout = open(SagaUtils.sagaBatchJobFilename(), "w")
if SextanteUtils.isWindows():
fout.write("set SAGA=" + SagaUtils.sagaPath() + "\n");
fout.write("set SAGA_MLB=" + SagaUtils.sagaPath()+ os.sep + "modules" + "\n");
fout.write("set SAGA_MLB=" + SagaUtils.sagaPath() + os.sep + "modules" + "\n");
fout.write("PATH=PATH;%SAGA%;%SAGA_MLB%\n");
elif SextanteUtils.isMac():
fout.write("export SAGA_MLB=" + SagaUtils.sagaPath() + "/../lib/saga\n");
fout.write("export PATH=" + SagaUtils.sagaPath() + ":$PATH\n");
else:
pass
for command in commands:
Expand Down

0 comments on commit baedeb2

Please sign in to comment.