Skip to content

Commit

Permalink
[processing] improve temp file names generation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 12, 2016
1 parent b6d5f35 commit dff239c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions python/plugins/processing/tools/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import time
import sys
import uuid
import math

from qgis.PyQt.QtCore import QDir
from qgis.core import QgsApplication
Expand Down Expand Up @@ -81,13 +82,14 @@ def setTempOutput(out, alg):


def getTempFilename(ext=None):
path = tempFolder()
tmpPath = tempFolder()
t = time.time()
m = math.floor(t)
uid = '{:8x}{:05x}'.format(m, int((t - m) * 1000000))
if ext is None:
filename = path + os.sep + str(time.time()) \
+ str(getNumExportedLayers())
filename = os.path.join(tmpPath, '{}{}'.format(uid, getNumExportedLayers()))
else:
filename = path + os.sep + str(time.time()) \
+ str(getNumExportedLayers()) + '.' + ext
filename = os.path.join(tmpPath, '{}{}.{}'.format(uid, getNumExportedLayers(), ext))
return filename


Expand Down

0 comments on commit dff239c

Please sign in to comment.