diff --git a/python/plugins/processing/core/LayerExporter.py b/python/plugins/processing/core/LayerExporter.py index a82115da6fa..47788cc3cb3 100644 --- a/python/plugins/processing/core/LayerExporter.py +++ b/python/plugins/processing/core/LayerExporter.py @@ -29,7 +29,6 @@ from processing.core.ProcessingUtils import ProcessingUtils from qgis.core import * from PyQt4.QtCore import * from PyQt4.QtGui import * -from processing.gdal.GdalUtils import GdalUtils class LayerExporter(): diff --git a/python/plugins/processing/core/ProcessingUtils.py b/python/plugins/processing/core/ProcessingUtils.py index f3fe79ce1a4..5b39a573f24 100644 --- a/python/plugins/processing/core/ProcessingUtils.py +++ b/python/plugins/processing/core/ProcessingUtils.py @@ -61,11 +61,7 @@ class ProcessingUtils: @staticmethod def setTempOutput(out, alg): ext = out.getDefaultFileExtension(alg) - validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - safeCmdName = ''.join(c for c in alg.commandLineName() if c in validChars) - uniqueSufix = str(uuid.uuid4()).replace("-","") - filename = ProcessingUtils.tempFolder() + os.sep + safeCmdName + uniqueSufix + "." + ext - out.value = filename + out.value = ProcessingUtils.getTempFilenameInTempFolder(out.name + "." + ext) @staticmethod def getTempFilename(ext): diff --git a/python/plugins/processing/outputs/OutputRaster.py b/python/plugins/processing/outputs/OutputRaster.py index ba17ed9532e..6cbcc0c0268 100644 --- a/python/plugins/processing/outputs/OutputRaster.py +++ b/python/plugins/processing/outputs/OutputRaster.py @@ -49,6 +49,6 @@ class OutputRaster(Output): return self.value else: if self.compatible is None: - self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg)) + self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg)) return self.compatible; diff --git a/python/plugins/processing/outputs/OutputTable.py b/python/plugins/processing/outputs/OutputTable.py index 3ff362a4cc2..4a70a8417d3 100644 --- a/python/plugins/processing/outputs/OutputTable.py +++ b/python/plugins/processing/outputs/OutputTable.py @@ -52,7 +52,7 @@ class OutputTable(Output): return self.value else: if self.compatible is None: - self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg)) + self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg)) return self.compatible; def getTableWriter(self, fields): diff --git a/python/plugins/processing/outputs/OutputVector.py b/python/plugins/processing/outputs/OutputVector.py index 6b2cd5a94bb..4971a5b634f 100644 --- a/python/plugins/processing/outputs/OutputVector.py +++ b/python/plugins/processing/outputs/OutputVector.py @@ -55,7 +55,7 @@ class OutputVector(Output): return self.value else: if self.compatible is None: - self.compatible = ProcessingUtils.getTempFilename(self.getDefaultFileExtension(alg)) + self.compatible = ProcessingUtils.getTempFilenameInTempFolder(self.name + "." + self.getDefaultFileExtension(alg)) return self.compatible; diff --git a/python/plugins/processing/saga/SagaAlgorithm.py b/python/plugins/processing/saga/SagaAlgorithm.py index afdd66b1175..65703a71f10 100644 --- a/python/plugins/processing/saga/SagaAlgorithm.py +++ b/python/plugins/processing/saga/SagaAlgorithm.py @@ -206,7 +206,7 @@ class SagaAlgorithm(GeoAlgorithm): filename = LayerExporter.exportVectorLayer(layer) self.exportedLayers[param.value]=filename elif not param.value.endswith("shp"): - raise GeoAlgorithmExecutionException("Unsupported file format") + raise GeoAlgorithmExecutionException("Unsupported file format") if isinstance(param, ParameterTable): if param.value == None: continue @@ -378,14 +378,25 @@ class SagaAlgorithm(GeoAlgorithm): return s - def exportRasterLayer(self, layer): - destFilename = ProcessingUtils.getTempFilenameInTempFolder(os.path.basename(layer)[0:5] + ".sgrd") - self.exportedLayers[layer]= destFilename + def exportRasterLayer(self, source): + layer = QGisLayers.getObjectFromUri(source, False) + if layer: + filename = str(layer.name()) + else: + filename = source.rstrip(".sgrd") + validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:" + filename = ''.join(c for c in filename if c in validChars) + if len(filename) == 0: + filename = "layer" + destFilename = ProcessingUtils.getTempFilenameInTempFolder(filename + ".sgrd") + self.exportedLayers[source]= destFilename saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208) if ProcessingUtils.isWindows() or ProcessingUtils.isMac() or not saga208: - return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer+"\"" + return "io_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + source+"\"" else: - return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + layer + "\"" + return "libio_gdal 0 -GRIDS \"" + destFilename + "\" -FILES \"" + source + "\"" + + def checkBeforeOpeningParametersDialog(self):