Skip to content
Permalink
Browse files
follow up 5ad518afd2. Better handling of temporary directories
  • Loading branch information
alexbruy committed May 16, 2014
1 parent 50a258d commit 6088dbacacba74b202387df3b15f4e24577cd54f
Showing with 19 additions and 7 deletions.
  1. +1 −4 python/plugins/processing/algs/qgis/PointsToPaths.py
  2. +1 −1 python/plugins/processing/outputs/OutputDirectory.py
  3. +17 −2 python/plugins/processing/tools/system.py
@@ -119,10 +119,7 @@ def processAlgorithm(self, progress):
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 @@


class OutputDirectory(Output):
pass
directory = True
@@ -29,7 +29,9 @@
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:.'

0 comments on commit 6088dba

Please sign in to comment.