Permalink
Browse files

Cleaning up temporary files in emscripten.py.

  • Loading branch information...
1 parent f0bb154 commit eef9e588e00a0f22f5ca66e8925c26bfd22b38d0 @max99x max99x committed Jul 8, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 emscripten.py
View
@@ -9,7 +9,7 @@
import tools.shared as shared
-# TODO: Clean up temporary files.
+TEMP_FILES_TO_CLEAN = []
def path_from_root(*target):
@@ -20,8 +20,10 @@ def path_from_root(*target):
def get_temp_file(suffix):
"""Returns a named temp file with the given prefix."""
- return tempfile.NamedTemporaryFile(
+ named_file = tempfile.NamedTemporaryFile(
dir=shared.TEMP_DIR, suffix=suffix, delete=False)
+ TEMP_FILES_TO_CLEAN.append(named_file.name)
+ return named_file
def assemble(filepath):
@@ -161,6 +163,10 @@ def main(args):
# Compile the assembly to Javascript.
emscript(args.infile, json.dumps(settings), args.outfile)
+ # Clean up temporary files.
+ for filename in TEMP_FILES_TO_CLEAN:
+ os.unlink(filename)
+
if __name__ == '__main__':
parser = argparse.ArgumentParser(

0 comments on commit eef9e58

Please sign in to comment.