Skip to content
Permalink
Browse files

Fix showing gdal command in algorithm dialog

  • Loading branch information
nyalldawson committed Aug 13, 2017
1 parent 3d3d297 commit ba6e2dc940ee2e7058396dfbfd976d7fe4997d4f
@@ -37,13 +37,15 @@
QSizePolicy,
QDialogButtonBox)

from qgis.core import QgsProcessingFeedback
from qgis.gui import QgsMessageBar

from processing.gui.AlgorithmDialog import AlgorithmDialog
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
from processing.gui.ParametersPanel import ParametersPanel
from processing.gui.MultipleInputPanel import MultipleInputPanel
from processing.gui.NumberInputPanel import NumberInputPanel
from processing.tools.dataobjects import createContext


class GdalAlgorithmDialog(AlgorithmDialog):
@@ -102,15 +104,15 @@ def connectParameterSignals(self):
w.hasChanged.connect(self.parametersHaveChanged)

def parametersHaveChanged(self):
context = createContext()
feedback = QgsProcessingFeedback()
try:
parameters = self.parent.getParamValues()
for output in self.alg.destinationParameterDefinitions():
if parameters[output.name()] is None:
if not output.name() in parameters or parameters[output.name()] is None:
parameters[output.name()] = self.tr("[temporary file]")
commands = self.alg.getConsoleCommands(parameters)
commands = self.alg.getConsoleCommands(parameters, context, feedback)
commands = [c for c in commands if c not in ['cmd.exe', '/C ']]
self.text.setPlainText(" ".join(commands))
except AlgorithmDialogBase.InvalidParameterValue as e:
self.text.setPlainText(self.tr("Invalid value for parameter '{0}'").format(e.parameter.description()))
except:
self.text.setPlainText("")
@@ -198,7 +198,8 @@ def escapeAndJoin(strList):
+ '"'
else:
escaped = s
joined += escaped + ' '
if escaped is not None:
joined += escaped + ' '
return joined.strip()

@staticmethod
@@ -245,7 +246,7 @@ def ogrConnectionStringAndFormat(uri, context):
if layer is None:
path, ext = os.path.splitext(uri)
format = QgsVectorFileWriter.driverForExtension(ext)
return '"' + uri + '"', format
return '"' + uri + '"', '"' + format + '"'

provider = layer.dataProvider().name()
if provider == 'spatialite':
@@ -317,7 +318,7 @@ def ogrConnectionStringAndFormat(uri, context):
path, ext = os.path.splitext(ogrstr)
format = QgsVectorFileWriter.driverForExtension(ext)

return '"' + ogrstr + '"', format
return '"' + ogrstr + '"', '"' + format + '"'

@staticmethod
def ogrLayerName(uri):
@@ -93,6 +93,9 @@ def runAsBatch(self):
def getParamValues(self):
parameters = {}

if not hasattr(self, 'mainWidget') or self.mainWidget is None:
return parameters

for param in self.alg.parameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue

0 comments on commit ba6e2dc

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