Skip to content

Commit 0d1ab70

Browse files
committed
processing: improve saga detection on windows
1 parent d9abe1e commit 0d1ab70

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,17 @@ def findSagaFolder():
6767
if os.path.exists(os.path.join(testfolder, 'saga_cmd')):
6868
folder = testfolder
6969
elif isWindows():
70-
testfolder = os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga')
71-
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
72-
folder = testfolder
70+
folders = []
71+
folders.append(os.path.join(os.path.dirname(QgsApplication.prefixPath()), 'saga'))
72+
if "OSGEO4W_ROOT" in os.environ:
73+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga-ltr"))
74+
folders.append(os.path.join(str(os.environ['OSGEO4W_ROOT']), "apps", "saga"))
75+
76+
for testfolder in folders:
77+
if os.path.exists(os.path.join(testfolder, 'saga_cmd.exe')):
78+
folder = testfolder
79+
break
80+
7381
return folder
7482

7583

@@ -161,8 +169,8 @@ def executeSaga(feedback):
161169
if isWindows():
162170
command = ['cmd.exe', '/C ', sagaBatchJobFilename()]
163171
else:
164-
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC
165-
| stat.S_IREAD | stat.S_IWRITE)
172+
os.chmod(sagaBatchJobFilename(), stat.S_IEXEC |
173+
stat.S_IREAD | stat.S_IWRITE)
166174
command = [sagaBatchJobFilename()]
167175
loglines = []
168176
loglines.append(QCoreApplication.translate('SagaUtils', 'SAGA execution console output'))

0 commit comments

Comments
 (0)