Skip to content

Commit

Permalink
[processing] rename GdalOgr provider to Gdal provider
Browse files Browse the repository at this point in the history
Show version numbers in providers descriptions
  • Loading branch information
alexbruy committed Dec 31, 2016
1 parent 248e7d1 commit ce9c08f
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 18 deletions.
Expand Up @@ -86,7 +86,7 @@
os.path.split(os.path.dirname(__file__))[0], os.pardir))


class GdalOgrAlgorithmProvider(AlgorithmProvider):
class GdalAlgorithmProvider(AlgorithmProvider):

"""This provider incorporates GDAL-based algorithms into the
Processing framework.
Expand All @@ -100,10 +100,11 @@ def __init__(self):
self.createAlgsList()

def getDescription(self):
return self.tr('GDAL/OGR')
version = GdalUtils.readableVersion()
return 'GDAL ({})'.format(version)

def getName(self):
return 'gdalogr'
return 'gdal'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Expand Up @@ -186,3 +186,7 @@ def escapeAndJoin(strList):
@staticmethod
def version():
return int(gdal.VersionInfo('VERSION_NUM'))

@staticmethod
def readableVersion():
return gdal.VersionInfo('RELEASE_NAME')
Expand Up @@ -92,10 +92,11 @@ def _loadAlgorithms(self):
self.algs = self.preloadedAlgs

def getDescription(self):
return self.tr('GRASS GIS 7 commands')
version = Grass7Utils.installedVersion()
return 'GRASS GIS ({})'.format(version) if version is not None else "GRASS GIS"

def getName(self):
return 'grass70'
return 'grass7'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))
Expand Down
43 changes: 38 additions & 5 deletions python/plugins/processing/algs/grass7/Grass7Utils.py
Expand Up @@ -35,6 +35,7 @@
from qgis.PyQt.QtCore import QCoreApplication
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
from processing.core.SilentProgress import SilentProgress
from processing.tools.system import userFolder, isWindows, isMac, tempFolder, mkdir
from processing.tests.TestData import points

Expand All @@ -56,6 +57,8 @@ class Grass7Utils(object):

isGrass7Installed = False

version = None

@staticmethod
def grassBatchJobFilename():
'''This is used in Linux. This is the batch job that we assign to
Expand All @@ -74,11 +77,41 @@ def grassScriptFilename():
filename = os.path.join(userFolder(), filename)
return filename

#~ @staticmethod
#~ def installedVersion():
#~ out = Grass7Utils.executeGrass7("grass -v")
#~ # FIXME: I do not know if this should be removed or let the user enter it
#~ # or something like that... This is just a temporary thing
#~ return '7.0.0'


@staticmethod
def getGrassVersion():
# FIXME: I do not know if this should be removed or let the user enter it
# or something like that... This is just a temporary thing
return '7.0.0'
def installedVersion(run=False):
if Grass7Utils.isGrass7Installed and not run:
return Grass7Utils.version

if Grass7Utils.grassPath() is None:
return None
commands = ["grass70 -v"]
with subprocess.Popen(
commands,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
universal_newlines=True,
) as proc:
try:
lines = proc.stdout.readlines()
for line in lines:
if "GRASS GIS " in line:
Grass7Utils.version = line.split(" ")[-1].strip()
break
except:
pass

return Grass7Utils.version


@staticmethod
def grassPath():
Expand Down Expand Up @@ -140,7 +173,7 @@ def createGrass7Script(commands):
output.write('if "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%PATH%\n')
output.write('if not "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%GRASS_ADDON_PATH%;%PATH%\n')
output.write('\n')
output.write('set GRASS_VERSION=' + Grass7Utils.getGrassVersion() + '\n')
output.write('set GRASS_VERSION=' + Grass7Utils.installedVersion() + '\n')
output.write('if not "%LANG%"=="" goto langset\n')
output.write('FOR /F "usebackq delims==" %%i IN (`"%WINGISBASE%\\etc\\winlocale"`) DO @set LANG=%%i\n')
output.write(':langset\n')
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/otb/OTBAlgorithmProvider.py
Expand Up @@ -48,7 +48,8 @@ def __init__(self):
self.activate = True

def getDescription(self):
return self.tr("Orfeo Toolbox (Image analysis)")
version = OTBUtils.getInstalledVersion()
return "Orfeo ToolBox ({})".format(version) if version is not None else "Orfeo ToolBox"

def getName(self):
return "otb"
Expand Down
Expand Up @@ -300,7 +300,7 @@ def getName(self):
return 'qgis'

def getDescription(self):
return self.tr('QGIS geoalgorithms')
return 'QGIS'

def getIcon(self):
return self._icon
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Expand Up @@ -86,7 +86,7 @@ def unload(self):

def _loadAlgorithms(self):
self.algs = []
version = SagaUtils.getSagaInstalledVersion(True)
version = SagaUtils.getInstalledVersion(True)
if version is None:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
Expand Down Expand Up @@ -121,8 +121,8 @@ def _loadAlgorithm(self, descriptionFile, version):
self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))

def getDescription(self):
version = SagaUtils.getSagaInstalledVersion()
return 'SAGA (%s)' % version if version is not None else 'SAGA'
version = SagaUtils.getInstalledVersion()
return 'SAGA ({})'.format(version) if version is not None else 'SAGA'

def getName(self):
return 'saga'
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/saga/SagaUtils.py
Expand Up @@ -112,7 +112,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
_installedVersionFound = False


def getSagaInstalledVersion(runSaga=False):
def getInstalledVersion(runSaga=False):
global _installedVersion
global _installedVersionFound

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/core/Processing.py
Expand Up @@ -57,7 +57,7 @@
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider
from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/tests/AlgorithmsTestBase.py
Expand Up @@ -47,7 +47,7 @@
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider
from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider
Expand Down

0 comments on commit ce9c08f

Please sign in to comment.