mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
follow up 5ad518afd2. Better handling of temporary directories
This commit is contained in:
parent
50a258df53
commit
6088dbacac
@ -119,9 +119,6 @@ class PointsToPaths(GeoAlgorithm):
|
|||||||
f['begin'] = vertices[0][0]
|
f['begin'] = vertices[0][0]
|
||||||
f['end'] = vertices[-1][0]
|
f['end'] = vertices[-1][0]
|
||||||
|
|
||||||
if dirName == '':
|
|
||||||
fileName = system.getTempFilenameInTempFolder('%s.txt' % group)
|
|
||||||
else:
|
|
||||||
fileName = os.path.join(dirName, '%s.txt' % group)
|
fileName = os.path.join(dirName, '%s.txt' % group)
|
||||||
|
|
||||||
fl = open(fileName, 'w')
|
fl = open(fileName, 'w')
|
||||||
|
@ -29,4 +29,4 @@ from processing.outputs.Output import Output
|
|||||||
|
|
||||||
|
|
||||||
class OutputDirectory(Output):
|
class OutputDirectory(Output):
|
||||||
pass
|
directory = True
|
||||||
|
@ -29,7 +29,9 @@ import os
|
|||||||
import time
|
import time
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
|
|
||||||
from qgis.core import *
|
from qgis.core import *
|
||||||
|
|
||||||
numExported = 1
|
numExported = 1
|
||||||
@ -61,6 +63,9 @@ def tempFolder():
|
|||||||
|
|
||||||
|
|
||||||
def setTempOutput(out, alg):
|
def setTempOutput(out, alg):
|
||||||
|
if hasattr(out, 'directory'):
|
||||||
|
out.value = getTempDirInTempFolder()
|
||||||
|
else:
|
||||||
ext = out.getDefaultFileExtension(alg)
|
ext = out.getDefaultFileExtension(alg)
|
||||||
out.value = getTempFilenameInTempFolder(out.name + '.' + ext)
|
out.value = getTempFilenameInTempFolder(out.name + '.' + ext)
|
||||||
|
|
||||||
@ -89,6 +94,16 @@ def getTempFilenameInTempFolder(basename):
|
|||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
|
def getTempDirInTempFolder():
|
||||||
|
"""Returns a temporary directory, putting it into a temp folder.
|
||||||
|
"""
|
||||||
|
|
||||||
|
path = tempFolder()
|
||||||
|
path = os.path.join(path, str(uuid.uuid4()).replace('-', ''))
|
||||||
|
mkdir(path)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
def removeInvalidChars(string):
|
def removeInvalidChars(string):
|
||||||
validChars = \
|
validChars = \
|
||||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.'
|
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user