I'd probably suggest using http://docs.python.org/2/library/tempfile.html  to create the temp_dir