Skip to content
Permalink
Browse files

fixed saga installation checking

  • Loading branch information
volaya authored and jef-n committed Sep 6, 2013
1 parent 0509bf2 commit b87f06d86b95f406dd40e2b7c8ff8469e58f4118
@@ -40,7 +40,6 @@ class SagaAlgorithmProvider(AlgorithmProvider):
def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = True
self.createAlgsList() #preloading algorithms to speed up

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
@@ -69,8 +68,9 @@ def unload(self):
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)

def createAlgsList(self):
self.preloadedAlgs = []

def _loadAlgorithms(self):
self.algs = []
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
folder = SagaUtils.sagaDescriptionPath()
for descriptionFile in os.listdir(folder):
@@ -84,18 +84,16 @@ def createAlgsList(self):
try:
alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
if alg.name.strip() != "":
self.preloadedAlgs.append(alg)
self.algs.append(alg)
else:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
except Exception,e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile +"\n" + str(e))
self.preloadedAlgs.append(SplitRGBBands())

def _loadAlgorithms(self):
self.algs = self.preloadedAlgs
self.algs.append(SplitRGBBands())

def getDescription(self):
return "SAGA"
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
return "SAGA (2.0.8)" if saga208 else "SAGA (2.1)"

def getName(self):
return "saga"
@@ -27,7 +27,7 @@
import stat
import traceback
import subprocess
from processing.tests.TestData import points
from processing.tests.TestData import polygons
from processing.core.ProcessingUtils import ProcessingUtils
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
@@ -149,7 +149,7 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):

try:
from processing import runalg
result = runalg("saga:polygoncentroids", points(), False, None)
result = runalg("saga:polygoncentroids", polygons(), 0, None)
if result is None or not os.path.exists(result['CENTROIDS']):
return "It seems that SAGA is not correctly installed in your system.\nPlease install it before running SAGA algorithms."
except:

0 comments on commit b87f06d

Please sign in to comment.
You can’t perform that action at this time.