diff --git a/python/plugins/processing/algs/gdal/GdalUtils.py b/python/plugins/processing/algs/gdal/GdalUtils.py index 9f10c290fbc..0013320a9a9 100644 --- a/python/plugins/processing/algs/gdal/GdalUtils.py +++ b/python/plugins/processing/algs/gdal/GdalUtils.py @@ -138,7 +138,7 @@ class GdalUtils: def escapeAndJoin(strList): joined = '' for s in strList: - if ' ' in s: + if s[0]!='-' and ' ' in s: escaped = '"' + s.replace('\\', '\\\\').replace('"', '\\"') \ + '"' else: diff --git a/python/plugins/processing/core/GeoAlgorithm.py b/python/plugins/processing/core/GeoAlgorithm.py index 44e0ede68eb..fc6e07da991 100644 --- a/python/plugins/processing/core/GeoAlgorithm.py +++ b/python/plugins/processing/core/GeoAlgorithm.py @@ -361,17 +361,10 @@ class GeoAlgorithm: if layer.source() == inputlayer: self.crs = layer.crs() return - if isinstance(param, ParameterRaster) \ - or isinstance(param, ParameterMultipleInput) \ - and param.datatype \ - == ParameterMultipleInput.TYPE_RASTER: - p = QgsProviderRegistry.instance().provider('gdal', - inputlayer) - else: - p = QgsProviderRegistry.instance().provider('ogr', - inputlayer) + p = dataobjects.getObjectFromUri(inputlayer) if p is not None: self.crs = p.crs() + p = None return try: from qgis.utils import iface diff --git a/python/plugins/processing/core/Processing.py b/python/plugins/processing/core/Processing.py index adfc166bb23..f93a5fbf656 100644 --- a/python/plugins/processing/core/Processing.py +++ b/python/plugins/processing/core/Processing.py @@ -286,24 +286,39 @@ class Processing: if alg is None: print 'Error: Algorithm not found\n' return - if len(args) != alg.getVisibleParametersCount() \ - + alg.getVisibleOutputsCount(): - print 'Error: Wrong number of parameters' - processing.alghelp(algOrName) - return - alg = alg.getCopy() - if isinstance(args, dict): - # Set params by name - for (name, value) in args.items(): - if alg.getParameterFromName(name).setValue(value): + + if len(args) == 1 and isinstance(args[0], dict): + # Set params by name and try to run the alg even if not all parameter values are provided, + # by using the default values instead. + setParams = [] + for (name, value) in args[0].items(): + param = alg.getParameterFromName(name) + if param and param.setValue(value): + setParams.append(name) continue - if alg.getOutputFromName(name).setValue(value): + output = alg.getOutputFromName(name) + if output and output.setValue(value): continue print 'Error: Wrong parameter value %s for parameter %s.' \ % (value, name) + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Wrong parameter value %s for parameter %s." \ + % (alg.name, value, name)) return + # fill any missing parameters with default values if allowed + for param in alg.parameters: + if param.name not in setParams: + if not param.setValue(None): + print ("Error: Missing parameter value for parameter %s." % (param.name)) + ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, "Error in %s. Missing parameter value for parameter %s." \ + % (alg.name, param.name)) + return else: + if len(args) != alg.getVisibleParametersCount() \ + + alg.getVisibleOutputsCount(): + print 'Error: Wrong number of parameters' + processing.alghelp(algOrName) + return i = 0 for param in alg.parameters: if not param.hidden: diff --git a/python/plugins/processing/gui/InputLayerSelectorPanel.py b/python/plugins/processing/gui/InputLayerSelectorPanel.py index 665d7bfb1da..dd589748c45 100644 --- a/python/plugins/processing/gui/InputLayerSelectorPanel.py +++ b/python/plugins/processing/gui/InputLayerSelectorPanel.py @@ -63,7 +63,7 @@ class InputLayerSelectorPanel(QtGui.QWidget): path = '' filename = QtGui.QFileDialog.getOpenFileName(self, self.param.description, path, - self.param.getFileFilter()) + 'All files(*.*);;' + self.param.getFileFilter()) if filename: self.text.addItem(filename, filename) self.text.setCurrentIndex(self.text.count() - 1) diff --git a/python/plugins/processing/gui/ProcessingToolbox.py b/python/plugins/processing/gui/ProcessingToolbox.py index 6b6e6f398de..d33c077adee 100644 --- a/python/plugins/processing/gui/ProcessingToolbox.py +++ b/python/plugins/processing/gui/ProcessingToolbox.py @@ -123,6 +123,10 @@ class ProcessingToolbox(QDockWidget, Ui_ProcessingToolbox): if isinstance(child, TreeProviderItem): if child.providerName == providerName: child.refresh() + # sort categories and items in categories + child.sortChildren(0, Qt.AscendingOrder) + for i in xrange(child.childCount()): + child.child(i).sortChildren(0, Qt.AscendingOrder) break def showPopupMenu(self, point):