Permalink
Browse files

Replace uuid by tempfile

Since uuid is only Python 2.5+, this small change allows to keep Python
2.4 compatibility.
  • Loading branch information...
1 parent 1d14155 commit 800859eb7c74c3869958bf883e3f1ae0bdfc3f57 @priteau priteau committed Jul 17, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 control/src/python/workspacecontrol/defaults/ImageEditing.py
@@ -5,7 +5,7 @@
import stat
import struct
import sys
-import uuid
+import tempfile
import zope.interface
import workspacecontrol.api.modules
@@ -304,10 +304,12 @@ def process_after_shutdown(self, local_file_set):
# copy and replace the link by it
filestat = os.stat(image_local_path)
if filestat[stat.ST_NLINK] > 1:
- tmpfile = image_local_path + uuid.uuid4().hex
- shutil.copy(image_local_path, tmpfile)
+ tmpfile = tempfile.mkstemp(dir=instance_dir)
+ os.close(tmpfile[0])
+ tmpfilename = tmpfile[1]
+ shutil.copy(image_local_path, tmpfilename)
os.unlink(image_local_path)
- os.rename(tmpfile, image_local_path)
+ os.rename(tmpfilename, image_local_path)
# Add write permissions to the image
os.chmod(image_local_path, 0600)

0 comments on commit 800859e

Please sign in to comment.