Skip to content

Commit ce9c08f

Browse files
committedDec 31, 2016
[processing] rename GdalOgr provider to Gdal provider
Show version numbers in providers descriptions
1 parent 248e7d1 commit ce9c08f

File tree

10 files changed

+58
-18
lines changed

10 files changed

+58
-18
lines changed
 

‎python/plugins/processing/algs/gdal/GdalOgrAlgorithmProvider.py renamed to ‎python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
os.path.split(os.path.dirname(__file__))[0], os.pardir))
8787

8888

89-
class GdalOgrAlgorithmProvider(AlgorithmProvider):
89+
class GdalAlgorithmProvider(AlgorithmProvider):
9090

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

102102
def getDescription(self):
103-
return self.tr('GDAL/OGR')
103+
version = GdalUtils.readableVersion()
104+
return 'GDAL ({})'.format(version)
104105

105106
def getName(self):
106-
return 'gdalogr'
107+
return 'gdal'
107108

108109
def getIcon(self):
109110
return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))

‎python/plugins/processing/algs/gdal/GdalUtils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,7 @@ def escapeAndJoin(strList):
186186
@staticmethod
187187
def version():
188188
return int(gdal.VersionInfo('VERSION_NUM'))
189+
190+
@staticmethod
191+
def readableVersion():
192+
return gdal.VersionInfo('RELEASE_NAME')

‎python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ def _loadAlgorithms(self):
9292
self.algs = self.preloadedAlgs
9393

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

9798
def getName(self):
98-
return 'grass70'
99+
return 'grass7'
99100

100101
def getIcon(self):
101102
return QIcon(os.path.join(pluginPath, 'images', 'grass.svg'))

‎python/plugins/processing/algs/grass7/Grass7Utils.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from qgis.PyQt.QtCore import QCoreApplication
3636
from processing.core.ProcessingConfig import ProcessingConfig
3737
from processing.core.ProcessingLog import ProcessingLog
38+
from processing.core.SilentProgress import SilentProgress
3839
from processing.tools.system import userFolder, isWindows, isMac, tempFolder, mkdir
3940
from processing.tests.TestData import points
4041

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

5758
isGrass7Installed = False
5859

60+
version = None
61+
5962
@staticmethod
6063
def grassBatchJobFilename():
6164
'''This is used in Linux. This is the batch job that we assign to
@@ -74,11 +77,41 @@ def grassScriptFilename():
7477
filename = os.path.join(userFolder(), filename)
7578
return filename
7679

80+
#~ @staticmethod
81+
#~ def installedVersion():
82+
#~ out = Grass7Utils.executeGrass7("grass -v")
83+
#~ # FIXME: I do not know if this should be removed or let the user enter it
84+
#~ # or something like that... This is just a temporary thing
85+
#~ return '7.0.0'
86+
87+
7788
@staticmethod
78-
def getGrassVersion():
79-
# FIXME: I do not know if this should be removed or let the user enter it
80-
# or something like that... This is just a temporary thing
81-
return '7.0.0'
89+
def installedVersion(run=False):
90+
if Grass7Utils.isGrass7Installed and not run:
91+
return Grass7Utils.version
92+
93+
if Grass7Utils.grassPath() is None:
94+
return None
95+
commands = ["grass70 -v"]
96+
with subprocess.Popen(
97+
commands,
98+
shell=True,
99+
stdout=subprocess.PIPE,
100+
stdin=subprocess.DEVNULL,
101+
stderr=subprocess.STDOUT,
102+
universal_newlines=True,
103+
) as proc:
104+
try:
105+
lines = proc.stdout.readlines()
106+
for line in lines:
107+
if "GRASS GIS " in line:
108+
Grass7Utils.version = line.split(" ")[-1].strip()
109+
break
110+
except:
111+
pass
112+
113+
return Grass7Utils.version
114+
82115

83116
@staticmethod
84117
def grassPath():
@@ -140,7 +173,7 @@ def createGrass7Script(commands):
140173
output.write('if "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%PATH%\n')
141174
output.write('if not "%GRASS_ADDON_PATH%"=="" set PATH=%WINGISBASE%\\bin;%WINGISBASE%\\lib;%GRASS_ADDON_PATH%;%PATH%\n')
142175
output.write('\n')
143-
output.write('set GRASS_VERSION=' + Grass7Utils.getGrassVersion() + '\n')
176+
output.write('set GRASS_VERSION=' + Grass7Utils.installedVersion() + '\n')
144177
output.write('if not "%LANG%"=="" goto langset\n')
145178
output.write('FOR /F "usebackq delims==" %%i IN (`"%WINGISBASE%\\etc\\winlocale"`) DO @set LANG=%%i\n')
146179
output.write(':langset\n')

‎python/plugins/processing/algs/otb/OTBAlgorithmProvider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def __init__(self):
4848
self.activate = True
4949

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

5354
def getName(self):
5455
return "otb"

‎python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def getName(self):
300300
return 'qgis'
301301

302302
def getDescription(self):
303-
return self.tr('QGIS geoalgorithms')
303+
return 'QGIS'
304304

305305
def getIcon(self):
306306
return self._icon

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def unload(self):
8686

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

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

127127
def getName(self):
128128
return 'saga'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def createSagaBatchJobFileFromSagaCommands(commands):
112112
_installedVersionFound = False
113113

114114

115-
def getSagaInstalledVersion(runSaga=False):
115+
def getInstalledVersion(runSaga=False):
116116
global _installedVersion
117117
global _installedVersionFound
118118

‎python/plugins/processing/core/Processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
5858
from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider
5959
from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
60-
from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
60+
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
6161
from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
6262
from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider
6363
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider

‎python/plugins/processing/tests/AlgorithmsTestBase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider
4848
from processing.algs.grass7.Grass7AlgorithmProvider import Grass7AlgorithmProvider
4949
from processing.algs.lidar.LidarToolsAlgorithmProvider import LidarToolsAlgorithmProvider
50-
from processing.algs.gdal.GdalOgrAlgorithmProvider import GdalOgrAlgorithmProvider
50+
from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
5151
from processing.algs.otb.OTBAlgorithmProvider import OTBAlgorithmProvider
5252
from processing.algs.r.RAlgorithmProvider import RAlgorithmProvider
5353
from processing.algs.saga.SagaAlgorithmProvider import SagaAlgorithmProvider

0 commit comments

Comments
 (0)