Skip to content

Commit 0378214

Browse files
committedMar 24, 2017
processing: improve saga detection on windows
(cherry picked from commit 0d1ab70)
1 parent 25d9df3 commit 0378214

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
@@ -64,9 +64,17 @@ def findSagaFolder():
6464
if os.path.exists(os.path.join(testfolder, 'saga_cmd')):
6565
folder = testfolder
6666
elif isWindows():
67-
testfolder = os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga')
68-
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
69-
folder = testfolder
67+
folders = []
68+
folders.append(os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga'))
69+
if "OSGEO4W_ROOT" in os.environ:
70+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga-ltr"))
71+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga"))
72+
73+
for testfolder in folders:
74+
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
75+
folder = testfolder
76+
break
77+
7078
return folder
7179

7280

@@ -164,8 +172,8 @@ def executeSaga(progress):
164172
if isWindows():
165173
command = ['cmd.exe', '/C ', sagaBatchJobFilename()]
166174
else:
167-
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC
168-
| stat.S_IREAD | stat.S_IWRITE)
175+
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC |
176+
stat.S_IREAD | stat.S_IWRITE)
169177
command = [sagaBatchJobFilename()]
170178
loglines = []
171179
loglines.append(QCoreApplication.translate('SagaUtils', 'SAGA execution console output'))

0 commit comments

Comments
 (0)
Please sign in to comment.