Skip to content

Commit 12ab928

Browse files
authoredJan 5, 2017
Merge pull request #3918 from alexbruy/processing-providers
Processing providers updates
2 parents 52b004a + c5835e9 commit 12ab928

29 files changed

+466
-442
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/gdal/GridAverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def getIcon(self):
6060
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))
6161

6262
def commandLineName(self):
63-
return "gdalogr:gridaverage"
63+
return "gdal:gridaverage"
6464

6565
def defineCharacteristics(self):
6666
self.name, self.i18n_name = self.trAlgorithm('Grid (Moving average)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def getIcon(self):
6565
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))
6666

6767
def commandLineName(self):
68-
return "gdalogr:griddatametrics"
68+
return "gdal:griddatametrics"
6969

7070
def defineCharacteristics(self):
7171
self.name, self.i18n_name = self.trAlgorithm('Grid (Data metrics)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def getIcon(self):
6464
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))
6565

6666
def commandLineName(self):
67-
return "gdalogr:gridinvdist"
67+
return "gdal:gridinvdist"
6868

6969
def defineCharacteristics(self):
7070
self.name, self.i18n_name = self.trAlgorithm('Grid (Inverse distance to a power)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def getIcon(self):
6060
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))
6161

6262
def commandLineName(self):
63-
return "gdalogr:gridnearestneighbor"
63+
return "gdal:gridnearestneighbor"
6464

6565
def defineCharacteristics(self):
6666
self.name, self.i18n_name = self.trAlgorithm('Grid (Nearest neighbor)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class gdal2tiles(GdalAlgorithm):
6161
WEBVIEWERS = ['all', 'google', 'openlayers', 'leaflet', 'none']
6262

6363
def commandLineName(self):
64-
return "gdalogr:gdal2tiles"
64+
return "gdal:gdal2tiles"
6565

6666
def defineCharacteristics(self):
6767
self.name, self.i18n_name = self.trAlgorithm('gdal2tiles')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def getIcon(self):
6767
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png'))
6868

6969
def commandLineName(self):
70-
return "gdalogr:overviews"
70+
return "gdal:overviews"
7171

7272
def defineCharacteristics(self):
7373
self.name, self.i18n_name = self.trAlgorithm('Build overviews (pyramids)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def getIcon(self):
5050
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))
5151

5252
def commandLineName(self):
53-
return "gdalorg:rasterinfo"
53+
return "gdal:gdalinfo"
5454

5555
def defineCharacteristics(self):
5656
self.name, self.i18n_name = self.trAlgorithm('Information')

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class OgrInfo(GdalAlgorithm):
4343
SUMMARY_ONLY = 'SUMMARY_ONLY'
4444
OUTPUT = 'OUTPUT'
4545

46+
def commandLineName(self):
47+
return "gdal:ogrinfo"
48+
4649
def defineCharacteristics(self):
4750
self.name, self.i18n_name = self.trAlgorithm('Information')
4851
self.group, self.i18n_group = self.trAlgorithm('[OGR] Miscellaneous')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def getIcon(self):
5050
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png'))
5151

5252
def commandLineName(self):
53-
return "gdalogr:polygonize"
53+
return "gdal:polygonize"
5454

5555
def defineCharacteristics(self):
5656
self.name, self.i18n_name = self.trAlgorithm('Polygonize (raster to vector)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def getIcon(self):
6161
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'proximity.png'))
6262

6363
def commandLineName(self):
64-
return "gdalogr:proximity"
64+
return "gdal:proximity"
6565

6666
def defineCharacteristics(self):
6767
self.name, self.i18n_name = self.trAlgorithm('Proximity (raster distance)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def getIcon(self):
7474
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))
7575

7676
def commandLineName(self):
77-
return "gdalogr:rasterize"
77+
return "gdal:rasterize"
7878

7979
def defineCharacteristics(self):
8080
self.name, self.i18n_name = self.trAlgorithm('Rasterize (vector to raster)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def getIcon(self):
5252
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))
5353

5454
def commandLineName(self):
55-
return "gdalogr:rasterize_over"
55+
return "gdal:rasterize_over"
5656

5757
def defineCharacteristics(self):
5858
self.name, self.i18n_name = self.trAlgorithm('Rasterize (write over existing raster)')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class retile(GdalAlgorithm):
6161
ALGO = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos']
6262

6363
def commandLineName(self):
64-
return "gdalogr:retile"
64+
return "gdal:retile"
6565

6666
def commandName(self):
6767
return "gdal_retile"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def getIcon(self):
7373
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png'))
7474

7575
def commandLineName(self):
76-
return "gdalogr:translate"
76+
return "gdal:translate"
7777

7878
def defineCharacteristics(self):
7979
self.name, self.i18n_name = self.trAlgorithm('Translate (convert format)')

‎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/gui/algnames.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
gdalogr:executesql,Execute SQL on vector layer
2-
gdalogr:rasterinfo,Raster layer information
3-
gdalogr:merge,Merge raster layers
4-
gdalogr:ogr2ogr,Export vector layer
5-
gdalogr:vectorinfo,Vector layer information
6-
gdalogr:pcttorgb,PCT to RGB
7-
gdalogr:rgbtopct,RGB to PCT
8-
gdalogr:sieve,Remove small pixel clumps (nearest neighbour)
9-
gdalogr:translate,Export raster layer
10-
gdalogr:warpreproject,Reproject raster layer
11-
gdalogr:polygonize,Vectorize raster layer
12-
gdalogr:gridrasterize,Rasterize vector layer
13-
gdalogr:gridnearestneighbor,Interpolate (Nearest Neighbor)
14-
gdalogr:griddatametrics,Interpolate (Data metrics)
15-
gdalogr:gridinvdist,Interpolate (Inverse distance weighting)
16-
gdalogr:gridaverage,Interpolate (Average)
17-
gdalogr:contour,Contour lines
1+
gdal:executesql,Execute SQL on vector layer
2+
gdal:rasterinfo,Raster layer information
3+
gdal:merge,Merge raster layers
4+
gdal:ogr2ogr,Export vector layer
5+
gdal:vectorinfo,Vector layer information
6+
gdal:pcttorgb,PCT to RGB
7+
gdal:rgbtopct,RGB to PCT
8+
gdal:sieve,Remove small pixel clumps (nearest neighbour)
9+
gdal:translate,Export raster layer
10+
gdal:warpreproject,Reproject raster layer
11+
gdal:polygonize,Vectorize raster layer
12+
gdal:gridrasterize,Rasterize vector layer
13+
gdal:gridnearestneighbor,Interpolate (Nearest Neighbor)
14+
gdal:griddatametrics,Interpolate (Data metrics)
15+
gdal:gridinvdist,Interpolate (Inverse distance weighting)
16+
gdal:gridaverage,Interpolate (Average)
17+
gdal:contour,Contour lines
1818
qgis:creategrid,Create graticule
1919
saga:changegridvalues,Reclassify (simple)
2020
saga:creategraticule,Create graticule from extent

0 commit comments

Comments
 (0)
Please sign in to comment.