Skip to content
Permalink
Browse files
fixed saga installation checking
  • Loading branch information
volaya committed Sep 6, 2013
1 parent 5482f14 commit 6689964b47aa744ed7d3136bec6e72d36d52b699
Showing with 12 additions and 14 deletions.
  1. +10 −12 python/plugins/processing/saga/SagaAlgorithmProvider.py
  2. +2 −2 python/plugins/processing/saga/SagaUtils.py
@@ -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)
@@ -68,34 +67,33 @@ def unload(self):
ProcessingConfig.removeSetting(SagaUtils.SAGA_RESAMPLING_REGION_CELLSIZE)
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)


def createAlgsList(self):
self.preloadedAlgs = []
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
def _loadAlgorithms(self):
self.algs = []
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
folder = SagaUtils.sagaDescriptionPath()
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith("txt"):
if descriptionFile.endswith("txt"):
if not saga208:
if descriptionFile.startswith("2.0.8"):
continue
else:
if descriptionFile.startswith("2.1"):
if descriptionFile.startswith("2.1"):
continue
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:

1 comment on commit 6689964

@gioman

This comment has been minimized.

Copy link
Contributor

@gioman gioman commented on 6689964 Sep 6, 2013

It there any chance to port this fix to the 2.0 branch?

Please sign in to comment.