Skip to content
Permalink
Browse files

[sextante] added better autoconfiguration for external apps' paths

  • Loading branch information
volaya committed Apr 21, 2013
1 parent b938724 commit bb97fc8b558d73d8eea8c12a0ff7a7da23bf2f58
@@ -34,7 +34,6 @@
from sextante.core.SextanteLog import SextanteLog
import stat
import shutil
import plugin_installer

class GrassUtils:

@@ -76,16 +75,14 @@ def grassPath():

folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
if folder == None:
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
if SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "grass")
if os.path.isdir(testfolder):
for subfolder in os.listdir(testfolder):
if subfolder.startswith("grass"):
folder = os.path.join(testfolder, subfolder)
break
else:
folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
if not os.path.isdir(folder):
@@ -97,10 +94,8 @@ def grassPath():
def grassWinShell():
folder = SextanteConfig.getSetting(GrassUtils.GRASS_WIN_SHELL)
if folder == None:
folder = plugin_installer.__file__
idx = folder.find('qgis')
folder = folder[:idx] + "msys"

folder = os.path.dirname(str(QgsApplication.prefixPath()))
folder = os.path.join(folder, "msys")
return folder

@staticmethod
@@ -35,7 +35,7 @@ class OTBAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.activate = True
self.createAlgsList()


@@ -42,7 +42,7 @@ def otbPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
if folder == None:
folder = ""

#try to configure the path automatically
if SextanteUtils.isMac():
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
if os.path.exists(os.path.join(testfolder, "otbcli")):
@@ -51,6 +51,13 @@ def otbPath():
testfolder = "/usr/local/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.dirname(testfolder)
testfolder = os.path.join(testfolder, "bin")
path = os.path.join(testfolder, "otbcli.bat")
if os.path.exists(path):
folder = testfolder
else:
testfolder = "/usr/bin"
if os.path.exists(os.path.join(testfolder, "otbcli")):
@@ -62,19 +69,25 @@ def otbLibPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
if folder == None:
folder =""

#try to configure the path automatically
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
folder = testfolder
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "orfeotoolbox")
testfolder = os.path.join(testfolder, "applications")
if os.path.exists(testfolder):
folder = testfolder
else:
testfolder = "/usr/lib/otb/applications"
if os.path.exists(testfolder):
folder = testfolder
folder = testfolder
return folder

@staticmethod
@@ -39,7 +39,7 @@ class SagaAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.activate = True
self.createAlgsList() #preloading algorithms to speed up

def initializeSettings(self):
@@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
@@ -28,6 +27,7 @@
import stat
import traceback
import subprocess
from sextante.tests.TestData import points
from sextante.core.SextanteUtils import SextanteUtils
from sextante.core.SextanteConfig import SextanteConfig
from sextante.core.SextanteLog import SextanteLog
@@ -63,15 +63,20 @@ def sagaPath():
folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
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"
#try to auto-configure the 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
elif SextanteUtils.isWindows():
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
testfolder = os.path.join(testfolder, "saga")
if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
folder = testfolder
return folder

@staticmethod

0 comments on commit bb97fc8

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