Skip to content

Commit

Permalink
fixed saga installation checking
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Sep 6, 2013
1 parent 5482f14 commit 6689964
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 10 additions & 12 deletions python/plugins/processing/saga/SagaAlgorithmProvider.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/saga/SagaUtils.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

1 comment on commit 6689964

@gioman
Copy link
Contributor

@gioman gioman commented on 6689964 Sep 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.