Skip to content

Commit b87f06d

Browse files
volayajef-n
authored andcommittedSep 6, 2013
fixed saga installation checking
1 parent 0509bf2 commit b87f06d

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed
 

‎python/plugins/processing/saga/SagaAlgorithmProvider.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class SagaAlgorithmProvider(AlgorithmProvider):
4040
def __init__(self):
4141
AlgorithmProvider.__init__(self)
4242
self.activate = True
43-
self.createAlgsList() #preloading algorithms to speed up
4443

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

72-
def createAlgsList(self):
73-
self.preloadedAlgs = []
71+
72+
def _loadAlgorithms(self):
73+
self.algs = []
7474
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
7575
folder = SagaUtils.sagaDescriptionPath()
7676
for descriptionFile in os.listdir(folder):
@@ -84,18 +84,16 @@ def createAlgsList(self):
8484
try:
8585
alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
8686
if alg.name.strip() != "":
87-
self.preloadedAlgs.append(alg)
87+
self.algs.append(alg)
8888
else:
8989
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile)
9090
except Exception,e:
9191
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Could not open SAGA algorithm: " + descriptionFile +"\n" + str(e))
92-
self.preloadedAlgs.append(SplitRGBBands())
93-
94-
def _loadAlgorithms(self):
95-
self.algs = self.preloadedAlgs
92+
self.algs.append(SplitRGBBands())
9693

9794
def getDescription(self):
98-
return "SAGA"
95+
saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
96+
return "SAGA (2.0.8)" if saga208 else "SAGA (2.1)"
9997

10098
def getName(self):
10199
return "saga"

‎python/plugins/processing/saga/SagaUtils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import stat
2828
import traceback
2929
import subprocess
30-
from processing.tests.TestData import points
30+
from processing.tests.TestData import polygons
3131
from processing.core.ProcessingUtils import ProcessingUtils
3232
from processing.core.ProcessingConfig import ProcessingConfig
3333
from processing.core.ProcessingLog import ProcessingLog
@@ -149,7 +149,7 @@ def checkSagaIsInstalled(ignoreRegistrySettings=False):
149149

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

0 commit comments

Comments
 (0)
Please sign in to comment.