Skip to content

Commit bb97fc8

Browse files
committedApr 21, 2013
[sextante] added better autoconfiguration for external apps' paths
1 parent b938724 commit bb97fc8

File tree

5 files changed

+42
-29
lines changed

5 files changed

+42
-29
lines changed
 

‎python/plugins/sextante/grass/GrassUtils.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from sextante.core.SextanteLog import SextanteLog
3535
import stat
3636
import shutil
37-
import plugin_installer
3837

3938
class GrassUtils:
4039

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

7776
folder = SextanteConfig.getSetting(GrassUtils.GRASS_FOLDER)
7877
if folder == None:
79-
if SextanteUtils.isWindows():
80-
folder = plugin_installer.__file__
81-
idx = folder.find('qgis')
82-
folder = folder[:idx] + "grass"
83-
if not os.path.isdir(folder):
84-
return ""
85-
for subfolder in os.listdir(folder):
86-
if subfolder.startswith("grass"):
87-
folder = folder + os.sep + subfolder
88-
break
78+
if SextanteUtils.isWindows():
79+
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
80+
testfolder = os.path.join(testfolder, "grass")
81+
if os.path.isdir(testfolder):
82+
for subfolder in os.listdir(testfolder):
83+
if subfolder.startswith("grass"):
84+
folder = os.path.join(testfolder, subfolder)
85+
break
8986
else:
9087
folder = os.path.join(str(QgsApplication.prefixPath()), "grass")
9188
if not os.path.isdir(folder):
@@ -97,10 +94,8 @@ def grassPath():
9794
def grassWinShell():
9895
folder = SextanteConfig.getSetting(GrassUtils.GRASS_WIN_SHELL)
9996
if folder == None:
100-
folder = plugin_installer.__file__
101-
idx = folder.find('qgis')
102-
folder = folder[:idx] + "msys"
103-
97+
folder = os.path.dirname(str(QgsApplication.prefixPath()))
98+
folder = os.path.join(folder, "msys")
10499
return folder
105100

106101
@staticmethod

‎python/plugins/sextante/otb/OTBAlgorithmProvider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class OTBAlgorithmProvider(AlgorithmProvider):
3535

3636
def __init__(self):
3737
AlgorithmProvider.__init__(self)
38-
self.activate = False
38+
self.activate = True
3939
self.createAlgsList()
4040

4141

‎python/plugins/sextante/otb/OTBUtils.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def otbPath():
4242
folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
4343
if folder == None:
4444
folder = ""
45-
45+
#try to configure the path automatically
4646
if SextanteUtils.isMac():
4747
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
4848
if os.path.exists(os.path.join(testfolder, "otbcli")):
@@ -51,6 +51,13 @@ def otbPath():
5151
testfolder = "/usr/local/bin"
5252
if os.path.exists(os.path.join(testfolder, "otbcli")):
5353
folder = testfolder
54+
elif SextanteUtils.isWindows():
55+
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
56+
testfolder = os.path.dirname(testfolder)
57+
testfolder = os.path.join(testfolder, "bin")
58+
path = os.path.join(testfolder, "otbcli.bat")
59+
if os.path.exists(path):
60+
folder = testfolder
5461
else:
5562
testfolder = "/usr/bin"
5663
if os.path.exists(os.path.join(testfolder, "otbcli")):
@@ -62,19 +69,25 @@ def otbLibPath():
6269
folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
6370
if folder == None:
6471
folder =""
65-
72+
#try to configure the path automatically
6673
if SextanteUtils.isMac():
6774
testfolder = os.path.join(str(QgsApplication.prefixPath()), "lib/otb/applications")
6875
if os.path.exists(testfolder):
6976
folder = testfolder
7077
else:
7178
testfolder = "/usr/local/lib/otb/applications"
7279
if os.path.exists(testfolder):
73-
folder = testfolder
80+
folder = testfolder
81+
elif SextanteUtils.isWindows():
82+
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
83+
testfolder = os.path.join(testfolder, "orfeotoolbox")
84+
testfolder = os.path.join(testfolder, "applications")
85+
if os.path.exists(testfolder):
86+
folder = testfolder
7487
else:
7588
testfolder = "/usr/lib/otb/applications"
7689
if os.path.exists(testfolder):
77-
folder = testfolder
90+
folder = testfolder
7891
return folder
7992

8093
@staticmethod

‎python/plugins/sextante/saga/SagaAlgorithmProvider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class SagaAlgorithmProvider(AlgorithmProvider):
3939

4040
def __init__(self):
4141
AlgorithmProvider.__init__(self)
42-
self.activate = False
42+
self.activate = True
4343
self.createAlgsList() #preloading algorithms to speed up
4444

4545
def initializeSettings(self):

‎python/plugins/sextante/saga/SagaUtils.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from sextante.tests.TestData import points
2019

2120
__author__ = 'Victor Olaya'
2221
__date__ = 'August 2012'
@@ -28,6 +27,7 @@
2827
import stat
2928
import traceback
3029
import subprocess
30+
from sextante.tests.TestData import points
3131
from sextante.core.SextanteUtils import SextanteUtils
3232
from sextante.core.SextanteConfig import SextanteConfig
3333
from sextante.core.SextanteLog import SextanteLog
@@ -63,15 +63,20 @@ def sagaPath():
6363
folder = SextanteConfig.getSetting(SagaUtils.SAGA_FOLDER)
6464
if folder == None:
6565
folder =""
66-
67-
if SextanteUtils.isMac():
68-
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
69-
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
70-
folder = testfolder
71-
else:
72-
testfolder = "/usr/local/bin"
66+
#try to auto-configure the folder
67+
if SextanteUtils.isMac():
68+
testfolder = os.path.join(str(QgsApplication.prefixPath()), "bin")
7369
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
7470
folder = testfolder
71+
else:
72+
testfolder = "/usr/local/bin"
73+
if os.path.exists(os.path.join(testfolder, "saga_cmd")):
74+
folder = testfolder
75+
elif SextanteUtils.isWindows():
76+
testfolder = os.path.dirname(str(QgsApplication.prefixPath()))
77+
testfolder = os.path.join(testfolder, "saga")
78+
if os.path.exists(os.path.join(testfolder, "saga_cmd.exe")):
79+
folder = testfolder
7580
return folder
7681

7782
@staticmethod

0 commit comments

Comments
 (0)