Skip to content

Commit 3d24b7a

Browse files
committedMar 24, 2017
processing: improve saga detection on windows
(cherry picked from commit 0d1ab70)
1 parent 35b7489 commit 3d24b7a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed
 

‎python/plugins/processing/algs/saga/SagaUtils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,17 @@ def findSagaFolder():
6363
if os.path.exists(os.path.join(testfolder, 'saga_cmd')):
6464
folder = testfolder
6565
elif isWindows():
66-
testfolder = os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga')
67-
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
68-
folder = testfolder
66+
folders = []
67+
folders.append(os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga'))
68+
if "OSGEO4W_ROOT" in os.environ:
69+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga-ltr"))
70+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga"))
71+
72+
for testfolder in folders:
73+
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
74+
folder = testfolder
75+
break
76+
6977
return folder
7078

7179

@@ -153,8 +161,8 @@ def executeSaga(progress):
153161
if isWindows():
154162
command = ['cmd.exe', '/C ', sagaBatchJobFilename()]
155163
else:
156-
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC
157-
| stat.S_IREAD | stat.S_IWRITE)
164+
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC |
165+
stat.S_IREAD | stat.S_IWRITE)
158166
command = [sagaBatchJobFilename()]
159167
loglines = []
160168
loglines.append(QCoreApplication.translate('SagaUtils', 'SAGA execution console output'))

0 commit comments

Comments
 (0)
Please sign in to comment.