Skip to content

Commit

Permalink
Fix showing gdal command in algorithm dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 13, 2017
1 parent 3d3d297 commit ba6e2dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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("")
7 changes: 4 additions & 3 deletions python/plugins/processing/algs/gdal/GdalUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def escapeAndJoin(strList):
+ '"'
else:
escaped = s
joined += escaped + ' '
if escaped is not None:
joined += escaped + ' '
return joined.strip()

@staticmethod
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/gui/AlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba6e2dc

Please sign in to comment.