Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
osgeo4w: run python scripts with python3 (fixes #20870)
(cherry picked from commit b6293f2)
  • Loading branch information
jef-n authored and nyalldawson committed Feb 11, 2019
1 parent 8953257 commit 8b8e6b8
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
Expand Up @@ -92,12 +92,9 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):

arguments.append(fileName)

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

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

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

return commands
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/gdal2tiles.py
Expand Up @@ -35,7 +35,6 @@
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
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(self.parameterAsString(parameters, self.OUTPUT, context))

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

return commands
9 changes: 2 additions & 7 deletions python/plugins/processing/algs/gdal/retile.py
Expand Up @@ -33,7 +33,6 @@
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFileDestination,
QgsProcessingParameterFolderDestination)
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)]
arguments.extend(layers)

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

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

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

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

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

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

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

return commands

0 comments on commit 8b8e6b8

Please sign in to comment.