Skip to content

Commit

Permalink
osgeo4w: run python scripts with python3 (fixes #20870)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 7, 2019
1 parent 83c6a2c commit b6293f2
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 66 deletions.
7 changes: 2 additions & 5 deletions python/plugins/processing/algs/gdal/AssignProjection.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -92,12 +92,9 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):


arguments.append(fileName) arguments.append(fileName)


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


self.setOutputValue(self.OUTPUT, fileName) self.setOutputValue(self.OUTPUT, fileName)
return commands return commands
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/fillnodata.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,12 +129,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(raster.source()) arguments.append(raster.source())
arguments.append(out) arguments.append(out)


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py',
GdalUtils.escapeAndJoin(arguments)]


return commands return commands
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/gdal2tiles.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
QgsProcessingParameterString, QgsProcessingParameterString,
QgsProcessingParameterNumber, QgsProcessingParameterNumber,
QgsProcessingParameterBoolean, QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFolderDestination) QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils from processing.algs.gdal.GdalUtils import GdalUtils
Expand Down Expand Up @@ -230,12 +229,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source()) arguments.append(inLayer.source())
arguments.append(self.parameterAsString(parameters, self.OUTPUT, context)) arguments.append(self.parameterAsString(parameters, self.OUTPUT, context))


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py',
GdalUtils.escapeAndJoin(arguments)]


return commands return commands
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/gdal2xyz.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
__revision__ = '$Format:%H$' __revision__ = '$Format:%H$'


from qgis.core import (QgsProcessingAlgorithm, from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProcessingException, QgsProcessingException,
QgsProcessingParameterRasterLayer, QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand, QgsProcessingParameterBand,
Expand Down Expand Up @@ -95,11 +94,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(raster.source()) arguments.append(raster.source())
arguments.append(self.parameterAsFileOutput(parameters, self.OUTPUT, context)) arguments.append(self.parameterAsFileOutput(parameters, self.OUTPUT, context))


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


return commands return commands
10 changes: 3 additions & 7 deletions python/plugins/processing/algs/gdal/merge.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
QgsProcessingParameterString, QgsProcessingParameterString,
QgsProcessingParameterBoolean, QgsProcessingParameterBoolean,
QgsProcessingParameterNumber, QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination, QgsProcessingParameterRasterDestination)
QgsProcessingUtils)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils from processing.algs.gdal.GdalUtils import GdalUtils


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


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


return commands return commands
7 changes: 2 additions & 5 deletions python/plugins/processing/algs/gdal/pct2rgb.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,11 +102,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
if self.parameterAsBool(parameters, self.RGBA, context): if self.parameterAsBool(parameters, self.RGBA, context):
arguments.append('-rgba') arguments.append('-rgba')


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


return commands return commands
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/polygonize.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import os import os


from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QFileInfo


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


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py',
GdalUtils.escapeAndJoin(arguments)]


return commands return commands
8 changes: 2 additions & 6 deletions python/plugins/processing/algs/gdal/proximity.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -186,12 +186,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(inLayer.source()) arguments.append(inLayer.source())
arguments.append(out) arguments.append(out)


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py',
GdalUtils.escapeAndJoin(arguments)]


return commands return commands
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/retile.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
QgsProcessingParameterString, QgsProcessingParameterString,
QgsProcessingParameterNumber, QgsProcessingParameterNumber,
QgsProcessingParameterBoolean, QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFileDestination, QgsProcessingParameterFileDestination,
QgsProcessingParameterFolderDestination) QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
Expand Down Expand Up @@ -210,12 +209,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
layers = [l.source() for l in self.parameterAsLayerList(parameters, self.INPUT, context)] layers = [l.source() for l in self.parameterAsLayerList(parameters, self.INPUT, context)]
arguments.extend(layers) arguments.extend(layers)


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py',
GdalUtils.escapeAndJoin(arguments)]


return commands return commands
7 changes: 2 additions & 5 deletions python/plugins/processing/algs/gdal/rgb2pct.py
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,3 @@

# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-


""" """
Expand Down Expand Up @@ -95,10 +94,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(raster.source()) arguments.append(raster.source())
arguments.append(out) arguments.append(out)


commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


return commands return commands
7 changes: 2 additions & 5 deletions python/plugins/processing/algs/gdal/sieve.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -119,11 +119,8 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append(raster.source()) arguments.append(raster.source())
arguments.append(out) arguments.append(out)


commands = [] commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]
if isWindows(): if isWindows():
commands = ['cmd.exe', '/C ', self.commandName() + '.bat', commands.insert(0, 'python3')
GdalUtils.escapeAndJoin(arguments)]
else:
commands = [self.commandName() + '.py', GdalUtils.escapeAndJoin(arguments)]


return commands return commands

0 comments on commit b6293f2

Please sign in to comment.