-# $Id$
-# $URL$
-
"""A few things that didn't seem to fit anywhere else."""
import os, os.path
import errno
import threading
import subprocess
+import shutil
import logger
def write_file(filename, do_write, **kw_args):
"""Write file <filename> atomically by opening a temporary file, using <do_write> to write that file, and then renaming the temporary file."""
- os.rename(write_temp_file(do_write, **kw_args), filename)
+ shutil.move(write_temp_file(do_write, **kw_args), filename)
def write_temp_file(do_write, mode=None, uidgid=None):
fd, temporary_filename = tempfile.mkstemp()
os.close(fd)
if os.path.exists(target):
os.unlink(target)
- os.rename(name,target)
+ shutil.move(name,target)
if chmod: os.chmod(target,chmod)
return True