Skip to content

Commit

Permalink
[sextante] added better autoconfiguration for external apps' paths
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Apr 21, 2013
1 parent b938724 commit bb97fc8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 29 deletions.
25 changes: 10 additions & 15 deletions python/plugins/sextante/grass/GrassUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from sextante.core.SextanteLog import SextanteLog
import stat
import shutil
import plugin_installer

class GrassUtils:

Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/otb/OTBAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class OTBAlgorithmProvider(AlgorithmProvider):

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


Expand Down
21 changes: 17 additions & 4 deletions python/plugins/sextante/otb/OTBUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand All @@ -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")):
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
21 changes: 13 additions & 8 deletions python/plugins/sextante/saga/SagaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from sextante.tests.TestData import points

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb97fc8

Please sign in to comment.