Skip to content
Permalink
Browse files

osgeo4w: run python scripts with python3 (fixes #20870)

  • Loading branch information
jef-n committed Jan 7, 2019
1 parent 83c6a2c commit b6293f23c8c54602f668f980f50d76ef09271e8a
@@ -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
@@ -129,12 +129,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
@@ -35,7 +35,6 @@
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
@@ -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
@@ -26,7 +26,6 @@
__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
@@ -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
@@ -37,8 +37,7 @@
QgsProcessingParameterString,
QgsProcessingParameterBoolean,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination,
QgsProcessingUtils)
QgsProcessingParameterRasterDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils

@@ -166,11 +165,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
@@ -102,11 +102,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
@@ -28,7 +28,6 @@
import os

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

from qgis.core import (QgsProcessing,
QgsProcessingException,
@@ -116,12 +115,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
@@ -186,12 +186,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
@@ -33,7 +33,6 @@
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFileDestination,
QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
@@ -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
@@ -1,4 +1,3 @@

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

"""
@@ -95,10 +94,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
@@ -119,11 +119,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 b6293f2

Please sign in to comment.
You can’t perform that action at this time.