diff options
author | max99x <max99x@gmail.com> | 2011-07-08 07:10:13 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-08 07:10:13 +0300 |
commit | eef9e588e00a0f22f5ca66e8925c26bfd22b38d0 (patch) | |
tree | bca0bd897298f7e879c37174b0e9d40cf8a8a584 | |
parent | f0bb1542292fcc78205d7b1660570b96a8052f2b (diff) |
Cleaning up temporary files in emscripten.py.
-rwxr-xr-x | emscripten.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/emscripten.py b/emscripten.py index a5ce0e09..4582a4e2 100755 --- a/emscripten.py +++ b/emscripten.py @@ -9,7 +9,7 @@ import tempfile 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( |