I am writing a QGIS plugin using SAGA by Processing. Is is possible to test whether SAGA is installed and which version is on?
For GDAL, it's OK with:
processing.tools.raster.gdal.__version__
You might to want to look at some of the python code for SAGA algorithm providers, especially the module SagaUtils.py - that has a getSagaInstalledVersion()
function, and a few functions for building the paths etc.
This is an example from the Python Console:-
>>> processing.algs.saga.SagaUtils.getSagaInstalledVersion()
'2.2.0'
Looking at the code, it's a wrapper around an external call to saga_cmd -v
with retry logic