mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
follow up 5ad518afd2. Better handling of temporary directories
This commit is contained in:
parent
50a258df53
commit
6088dbacac
@ -119,10 +119,7 @@ class PointsToPaths(GeoAlgorithm):
|
||||
f['begin'] = vertices[0][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.write('angle=Azimuth\n')
|
||||
|
@ -29,4 +29,4 @@ from processing.outputs.Output import Output
|
||||
|
||||
|
||||
class OutputDirectory(Output):
|
||||
pass
|
||||
directory = True
|
||||
|
@ -29,7 +29,9 @@ import os
|
||||
import time
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from qgis.core import *
|
||||
|
||||
numExported = 1
|
||||
@ -61,8 +63,11 @@ def tempFolder():
|
||||
|
||||
|
||||
def setTempOutput(out, alg):
|
||||
ext = out.getDefaultFileExtension(alg)
|
||||
out.value = getTempFilenameInTempFolder(out.name + '.' + ext)
|
||||
if hasattr(out, 'directory'):
|
||||
out.value = getTempDirInTempFolder()
|
||||
else:
|
||||
ext = out.getDefaultFileExtension(alg)
|
||||
out.value = getTempFilenameInTempFolder(out.name + '.' + ext)
|
||||
|
||||
|
||||
def getTempFilename(ext):
|
||||
@ -89,6 +94,16 @@ def getTempFilenameInTempFolder(basename):
|
||||
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):
|
||||
validChars = \
|
||||
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:.'
|
||||
|
Loading…
x
Reference in New Issue
Block a user