Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #4118 from alexbruy/processing-saga-ltr
[processing] support only SAGA LTR
  • Loading branch information
alexbruy committed Feb 10, 2017
2 parents a46afca + 732b501 commit c0eb997
Show file tree
Hide file tree
Showing 1,435 changed files with 25 additions and 10,915 deletions.
16 changes: 2 additions & 14 deletions python/plugins/processing/algs/saga/CMakeLists.txt
@@ -1,19 +1,7 @@
FILE(GLOB PY_FILES *.py)
FILE(GLOB DESCR212_FILES description/2.1.2/*.txt)
FILE(GLOB DESCR213_FILES description/2.1.3/*.txt)
FILE(GLOB DESCR214_FILES description/2.1.4/*.txt)
FILE(GLOB DESCR220_FILES description/2.2.0/*.txt)
FILE(GLOB DESCR222_FILES description/2.2.2/*.txt)
FILE(GLOB DESCR223_FILES description/2.2.3/*.txt)
FILE(GLOB HELP_FILES help/*.rst)
FILE(GLOB DESCR_FILES description/*.txt)

ADD_SUBDIRECTORY(ext)

PLUGIN_INSTALL(processing algs/saga ${PY_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.1.2 ${DESCR212_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.1.3 ${DESCR213_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.1.4 ${DESCR214_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.0 ${DESCR220_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.2 ${DESCR222_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.3 ${DESCR223_FILES})
PLUGIN_INSTALL(processing algs/saga/help ${HELP_FILES})
PLUGIN_INSTALL(processing algs/saga/description/ ${DESCR_FILES})
Expand Up @@ -62,7 +62,7 @@
sessionExportedLayers = {}


class SagaAlgorithm212(GeoAlgorithm):
class SagaAlgorithm(GeoAlgorithm):

OUTPUT_EXTENT = 'OUTPUT_EXTENT'

Expand Down
214 changes: 0 additions & 214 deletions python/plugins/processing/algs/saga/SagaAlgorithm213.py

This file was deleted.

64 changes: 0 additions & 64 deletions python/plugins/processing/algs/saga/SagaAlgorithm214.py

This file was deleted.

54 changes: 19 additions & 35 deletions python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Expand Up @@ -31,28 +31,18 @@
from processing.core.AlgorithmProvider import AlgorithmProvider
from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.ProcessingLog import ProcessingLog
from .SagaAlgorithm212 import SagaAlgorithm212
from .SagaAlgorithm213 import SagaAlgorithm213
from .SagaAlgorithm214 import SagaAlgorithm214
from .SplitRGBBands import SplitRGBBands
from . import SagaUtils
from processing.tools.system import isWindows, isMac

from .SagaAlgorithm import SagaAlgorithm
from .SplitRGBBands import SplitRGBBands
from . import SagaUtils

pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))


class SagaAlgorithmProvider(AlgorithmProvider):

supportedVersions = {"2.1.2": ("2.1.2", SagaAlgorithm212),
"2.1.3": ("2.1.3", SagaAlgorithm213),
"2.1.4": ("2.1.4", SagaAlgorithm214),
"2.2.0": ("2.2.0", SagaAlgorithm214),
"2.2.1": ("2.2.0", SagaAlgorithm214),
"2.2.2": ("2.2.2", SagaAlgorithm214),
"2.2.3": ("2.2.3", SagaAlgorithm214)}

def __init__(self):
super().__init__()
self.activate = True
Expand Down Expand Up @@ -91,34 +81,28 @@ def _loadAlgorithms(self):
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
return
if version not in self.supportedVersions:
lastVersion = sorted(self.supportedVersions.keys())[-1]
if version > lastVersion:
version = lastVersion
else:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Problem with SAGA installation: installed SAGA version (%s) is not supported' % version))
return

if version not in ['2.3.0', '2.3.1']:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Problem with SAGA installation: unsupported SAGA version found.'))
return

folder = SagaUtils.sagaDescriptionPath()
folder = os.path.join(folder, self.supportedVersions[version][0])
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('txt'):
f = os.path.join(folder, descriptionFile)
self._loadAlgorithm(f, version)
self.algs.append(SplitRGBBands())
try:
alg = SagaAlgorithm(os.path.join(folder, descriptionFile))
if alg.name.strip() != '':
self.algs.append(alg)
else:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not open SAGA algorithm: {}'.format(descriptionFile)))
except Exception as e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not open SAGA algorithm: {}\n{}'.format(descriptionFile, str(e))))

def _loadAlgorithm(self, descriptionFile, version):
try:
alg = self.supportedVersions[version][1](descriptionFile)
if alg.name.strip() != '':
self.algs.append(alg)
else:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not open SAGA algorithm: %s' % descriptionFile))
except Exception as e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))
self.algs.append(SplitRGBBands())

def name(self):
version = SagaUtils.getInstalledVersion()
Expand Down

0 comments on commit c0eb997

Please sign in to comment.