Skip to content

Commit

Permalink
Add FreeBSD for SagaUtils
Browse files Browse the repository at this point in the history
(cherry picked from commit f87c447)
  • Loading branch information
lbartoletti authored and nyalldawson committed Mar 7, 2019
1 parent 773964b commit fb19acf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions python/plugins/processing/algs/saga/SagaUtils.py
Expand Up @@ -26,6 +26,7 @@
__revision__ = '$Format:%H$' __revision__ = '$Format:%H$'


import os import os
import platform
import stat import stat
import subprocess import subprocess
import time import time
Expand Down Expand Up @@ -59,7 +60,7 @@ def sagaBatchJobFilename():


def findSagaFolder(): def findSagaFolder():
folder = None folder = None
if isMac(): if isMac() or platform.system() == 'FreeBSD':
testfolder = os.path.join(QgsApplication.prefixPath(), 'bin') testfolder = os.path.join(QgsApplication.prefixPath(), 'bin')
if os.path.exists(os.path.join(testfolder, 'saga_cmd')): if os.path.exists(os.path.join(testfolder, 'saga_cmd')):
folder = testfolder folder = testfolder
Expand All @@ -84,7 +85,7 @@ def findSagaFolder():




def sagaPath(): def sagaPath():
if not isWindows() and not isMac(): if not isWindows() and not isMac() and not platform.system() == 'FreeBSD':
return '' return ''


folder = findSagaFolder() folder = findSagaFolder()
Expand All @@ -102,7 +103,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
fout.write('set SAGA=' + sagaPath() + '\n') fout.write('set SAGA=' + sagaPath() + '\n')
fout.write('set SAGA_MLB=' + os.path.join(sagaPath(), 'modules') + '\n') fout.write('set SAGA_MLB=' + os.path.join(sagaPath(), 'modules') + '\n')
fout.write('PATH=%PATH%;%SAGA%;%SAGA_MLB%\n') fout.write('PATH=%PATH%;%SAGA%;%SAGA_MLB%\n')
elif isMac(): elif isMac() or platform.system() == 'FreeBSD':
fout.write('export SAGA_MLB=' + os.path.join(sagaPath(), '../lib/saga') + '\n') fout.write('export SAGA_MLB=' + os.path.join(sagaPath(), '../lib/saga') + '\n')
fout.write('export PATH=' + sagaPath() + ':$PATH\n') fout.write('export PATH=' + sagaPath() + ':$PATH\n')
else: else:
Expand All @@ -124,7 +125,7 @@ def getInstalledVersion(runSaga=False):


if isWindows(): if isWindows():
commands = [os.path.join(sagaPath(), "saga_cmd.exe"), "-v"] commands = [os.path.join(sagaPath(), "saga_cmd.exe"), "-v"]
elif isMac(): elif isMac() or platform.system() == 'FreeBSD':
commands = [os.path.join(sagaPath(), "saga_cmd -v")] commands = [os.path.join(sagaPath(), "saga_cmd -v")]
else: else:
# for Linux use just one string instead of separated parameters as the list # for Linux use just one string instead of separated parameters as the list
Expand All @@ -140,7 +141,7 @@ def getInstalledVersion(runSaga=False):
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
universal_newlines=True, universal_newlines=True,
) as proc: ) as proc:
if isMac(): # This trick avoids having an uninterrupted system call exception if SAGA is not installed if isMac() or platform.system() == 'FreeBSD': # This trick avoids having an uninterrupted system call exception if SAGA is not installed
time.sleep(1) time.sleep(1)
try: try:
lines = proc.stdout.readlines() lines = proc.stdout.readlines()
Expand Down

0 comments on commit fb19acf

Please sign in to comment.