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

This commit is contained in:
Juergen E. Fischer 2019-01-07 15:05:33 +01:00
parent 83c6a2c49b
commit b6293f23c8
11 changed files with 23 additions and 66 deletions

View File

@ -92,12 +92,9 @@ class AssignProjection(GdalAlgorithm):
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

View File

@ -129,12 +129,8 @@ class fillnodata(GdalAlgorithm):
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

View File

@ -35,7 +35,6 @@ from qgis.core import (QgsProcessingAlgorithm,
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
@ -230,12 +229,8 @@ class gdal2tiles(GdalAlgorithm):
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

View File

@ -26,7 +26,6 @@ __copyright__ = '(C) 2013, Alexander Bruy'
__revision__ = '$Format:%H$'
from qgis.core import (QgsProcessingAlgorithm,
QgsProcessing,
QgsProcessingException,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterBand,
@ -95,11 +94,8 @@ class gdal2xyz(GdalAlgorithm):
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

View File

@ -37,8 +37,7 @@ from qgis.core import (QgsRasterFileWriter,
QgsProcessingParameterString,
QgsProcessingParameterBoolean,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination,
QgsProcessingUtils)
QgsProcessingParameterRasterDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
@ -166,11 +165,8 @@ class merge(GdalAlgorithm):
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

View File

@ -102,11 +102,8 @@ class pct2rgb(GdalAlgorithm):
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

View File

@ -28,7 +28,6 @@ __revision__ = '$Format:%H$'
import os
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QFileInfo
from qgis.core import (QgsProcessing,
QgsProcessingException,
@ -116,12 +115,8 @@ class polygonize(GdalAlgorithm):
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

View File

@ -186,12 +186,8 @@ class proximity(GdalAlgorithm):
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

View File

@ -33,7 +33,6 @@ from qgis.core import (QgsProcessing,
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingOutputFolder,
QgsProcessingParameterFileDestination,
QgsProcessingParameterFolderDestination)
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
@ -210,12 +209,8 @@ class retile(GdalAlgorithm):
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

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
@ -95,10 +94,8 @@ class rgb2pct(GdalAlgorithm):
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

View File

@ -119,11 +119,8 @@ class sieve(GdalAlgorithm):
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