Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add FreeBSD for SagaUtils
(cherry picked from commit f87c447)
  • Loading branch information
lbartoletti authored and nyalldawson committed Mar 7, 2019
1 parent 483cf16 commit 53c2cc6
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$'

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

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


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

folder = findSagaFolder()
Expand All @@ -102,7 +103,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
fout.write('set SAGA=' + sagaPath() + '\n')
fout.write('set SAGA_MLB=' + os.path.join(sagaPath(), 'modules') + '\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 PATH=' + sagaPath() + ':$PATH\n')
else:
Expand All @@ -124,7 +125,7 @@ def getInstalledVersion(runSaga=False):

if isWindows():
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")]
else:
# 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,
universal_newlines=True,
) 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)
try:
lines = proc.stdout.readlines()
Expand Down

0 comments on commit 53c2cc6

Please sign in to comment.