Skip to content

Commit b6293f2

Browse files
committedJan 7, 2019
osgeo4w: run python scripts with python3 (fixes #20870)
1 parent 83c6a2c commit b6293f2

File tree

11 files changed

+23
-66
lines changed

11 files changed

+23
-66
lines changed
 

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,9 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
9292

9393
arguments.append(fileName)
9494

95-
commands = []
95+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
9696
if isWindows():
97-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
98-
GdalUtils.escapeAndJoin(arguments)]
99-
else:
100-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
97+
commands.insert(0, 'python3')
10198

10299
self.setOutputValue(self.OUTPUT, fileName)
103100
return commands

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
129129
arguments.append(raster.source())
130130
arguments.append(out)
131131

132-
commands = []
132+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
133133
if isWindows():
134-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
135-
GdalUtils.escapeAndJoin(arguments)]
136-
else:
137-
commands = [self.commandName() + '.py',
138-
GdalUtils.escapeAndJoin(arguments)]
134+
commands.insert(0, 'python3')
139135

140136
return commands

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
QgsProcessingParameterString,
3636
QgsProcessingParameterNumber,
3737
QgsProcessingParameterBoolean,
38-
QgsProcessingOutputFolder,
3938
QgsProcessingParameterFolderDestination)
4039
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
4140
from processing.algs.gdal.GdalUtils import GdalUtils
@@ -230,12 +229,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
230229
arguments.append(inLayer.source())
231230
arguments.append(self.parameterAsString(parameters, self.OUTPUT, context))
232231

233-
commands = []
232+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
234233
if isWindows():
235-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
236-
GdalUtils.escapeAndJoin(arguments)]
237-
else:
238-
commands = [self.commandName() + '.py',
239-
GdalUtils.escapeAndJoin(arguments)]
234+
commands.insert(0, 'python3')
240235

241236
return commands

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
__revision__ = '$Format:%H$'
2727

2828
from qgis.core import (QgsProcessingAlgorithm,
29-
QgsProcessing,
3029
QgsProcessingException,
3130
QgsProcessingParameterRasterLayer,
3231
QgsProcessingParameterBand,
@@ -95,11 +94,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
9594
arguments.append(raster.source())
9695
arguments.append(self.parameterAsFileOutput(parameters, self.OUTPUT, context))
9796

98-
commands = []
97+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
9998
if isWindows():
100-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
101-
GdalUtils.escapeAndJoin(arguments)]
102-
else:
103-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
99+
commands.insert(0, 'python3')
104100

105101
return commands

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
QgsProcessingParameterString,
3838
QgsProcessingParameterBoolean,
3939
QgsProcessingParameterNumber,
40-
QgsProcessingParameterRasterDestination,
41-
QgsProcessingUtils)
40+
QgsProcessingParameterRasterDestination)
4241
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
4342
from processing.algs.gdal.GdalUtils import GdalUtils
4443

@@ -166,11 +165,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
166165
arguments.append('--optfile')
167166
arguments.append(list_file)
168167

169-
commands = []
168+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
170169
if isWindows():
171-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
172-
GdalUtils.escapeAndJoin(arguments)]
173-
else:
174-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
170+
commands.insert(0, 'python3')
175171

176172
return commands

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
102102
if self.parameterAsBool(parameters, self.RGBA, context):
103103
arguments.append('-rgba')
104104

105-
commands = []
105+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
106106
if isWindows():
107-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
108-
GdalUtils.escapeAndJoin(arguments)]
109-
else:
110-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
107+
commands.insert(0, 'python3')
111108

112109
return commands

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import os
2929

3030
from qgis.PyQt.QtGui import QIcon
31-
from qgis.PyQt.QtCore import QFileInfo
3231

3332
from qgis.core import (QgsProcessing,
3433
QgsProcessingException,
@@ -116,12 +115,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
116115
arguments.append(layerName)
117116
arguments.append(self.parameterAsString(parameters, self.FIELD, context))
118117

119-
commands = []
118+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
120119
if isWindows():
121-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
122-
GdalUtils.escapeAndJoin(arguments)]
123-
else:
124-
commands = [self.commandName() + '.py',
125-
GdalUtils.escapeAndJoin(arguments)]
120+
commands.insert(0, 'python3')
126121

127122
return commands

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
186186
arguments.append(inLayer.source())
187187
arguments.append(out)
188188

189-
commands = []
189+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
190190
if isWindows():
191-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
192-
GdalUtils.escapeAndJoin(arguments)]
193-
else:
194-
commands = [self.commandName() + '.py',
195-
GdalUtils.escapeAndJoin(arguments)]
191+
commands.insert(0, 'python3')
196192

197193
return commands

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
QgsProcessingParameterString,
3434
QgsProcessingParameterNumber,
3535
QgsProcessingParameterBoolean,
36-
QgsProcessingOutputFolder,
3736
QgsProcessingParameterFileDestination,
3837
QgsProcessingParameterFolderDestination)
3938
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
@@ -210,12 +209,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
210209
layers = [l.source() for l in self.parameterAsLayerList(parameters, self.INPUT, context)]
211210
arguments.extend(layers)
212211

213-
commands = []
212+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
214213
if isWindows():
215-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
216-
GdalUtils.escapeAndJoin(arguments)]
217-
else:
218-
commands = [self.commandName() + '.py',
219-
GdalUtils.escapeAndJoin(arguments)]
214+
commands.insert(0, 'python3')
220215

221216
return commands

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# -*- coding: utf-8 -*-
32

43
"""
@@ -95,10 +94,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
9594
arguments.append(raster.source())
9695
arguments.append(out)
9796

97+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
9898
if isWindows():
99-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
100-
GdalUtils.escapeAndJoin(arguments)]
101-
else:
102-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
99+
commands.insert(0, 'python3')
103100

104101
return commands

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
119119
arguments.append(raster.source())
120120
arguments.append(out)
121121

122-
commands = []
122+
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
123123
if isWindows():
124-
commands = ['cmd.exe', '/C ', self.commandName() + '.bat',
125-
GdalUtils.escapeAndJoin(arguments)]
126-
else:
127-
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
124+
commands.insert(0, 'python3')
128125

129126
return commands

0 commit comments

Comments
 (0)
Please sign in to comment.