summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-09-12 21:52:10 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-09-12 21:52:10 +0000
commit7a7546b31745bdec1f0580e26d2290f31a5349dc (patch)
tree03d91a9f0a651192160f99906b241cc7f9cc61dc
parent775027a16959e8ac5cb3fcc939765c4a6d53fdc4 (diff)
efbb: Use mkstemp to create temporary file
SVN revision: 76564
-rwxr-xr-xtools/levels_create.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/levels_create.py b/tools/levels_create.py
index 17e4793..c255ae0 100755
--- a/tools/levels_create.py
+++ b/tools/levels_create.py
@@ -12,6 +12,7 @@ import sys
12import os 12import os
13import os.path 13import os.path
14import subprocess 14import subprocess
15import tempfile
15import ConfigParser 16import ConfigParser
16 17
17 18
@@ -59,8 +60,8 @@ def eet_struct_write(f, struct):
59 60
60 61
61def eet_desc_write(levels): 62def eet_desc_write(levels):
62 tmp_filename = '/tmp/game_levels.desc' 63 fd, tmp_filename = tempfile.mkstemp()
63 f = open(tmp_filename, 'w') 64 f = os.fdopen(fd, 'w')
64 r = eet_struct_write(f, levels) 65 r = eet_struct_write(f, levels)
65 f.close() 66 f.close()
66 if r: 67 if r:
@@ -241,6 +242,7 @@ def main(root, eet_filename):
241 desc_filename = eet_desc_write(levels) 242 desc_filename = eet_desc_write(levels)
242 if desc_filename: 243 if desc_filename:
243 eet_create(desc_filename, eet_filename) 244 eet_create(desc_filename, eet_filename)
245 os.unlink(desc_filename)
244 print "Done! File %s created with success." % eet_filename 246 print "Done! File %s created with success." % eet_filename
245 247
246 248