Pretty simple question that an internet search (or a few guesses in python) cant answer:
How can one programmatically determine which if any version of GRASS is available in pyQGIS
Best I could come up with was to query processing.alglist("grass") into a variable and regex the result. Pretty much what I did in an adhoc (by eye rather than regex) fashion to solve the immediate problem. But this seems silly.
An alternative idea was simply to run the desired algorithm, but that often returns nothing to the command line, as though it ran correctly. Making EAFP problematic.
Is there a simple way to query which if any version of GRASS is available?
As with @Joseph answer some information is available from grass...utils so:
grass = processing.algs.grass.Grass7Utils.GrassUtils grass7 = processing.algs.grass7.Grass7Utils.Grass7Utils
However, I had an error with
I also note that there is
grass.isGrassInstalled but the results dont nessasarily match whats available if I open processing/toolbox.
For example in my QGIS2.8 Grass 6.4.0 is installed and available from processing/toolbox but grass.isinstalled returns false. In my QGIS2.18(with GRASS7) grass 7 is available from the processing/toolbox but the getversion returns both 6.4.0 and 7.0.0 for the respective version numbers and .isinstalled returns false for both.
The upshot is there appears to be multiple ways to determine the availabilty of an available grass version with little sychronicity to the reality of which version is actually available in the toolbox.
Perhaps my (windows) installed versions of QGIS are interfering with each other? I'll need to test this on my linux machine too.