()
Prepare and enter a temporary directory, cleanup when done
Prepare and enter a temporary directory, cleanup when done
Prepare and enter a temporary directory cleanup when done
def tmp_chdir():
    "Prepare and enter a temporary directory, cleanup when done"

    # Threadsafe
    with tmp_chdir_lock:
        olddir = os.getcwd()
        try:
            tmpdir = tempfile.mkdtemp()
            os.chdir(tmpdir)
            yield tmpdir
        finally:
            os.chdir(olddir)
            shutil.rmtree(tmpdir)
def tmp_chdir ( ) : # Threadsafe with tmp_chdir_lock : olddir = os . getcwd ( ) try : tmpdir = tempfile . mkdtemp ( ) os . chdir ( tmpdir ) yield tmpdir finally : os . chdir ( olddir ) shutil . rmtree ( tmpdir )