X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools.py;h=36754fc9fc45547c766555d72fcce55107d1270e;hb=refs%2Fheads%2Fopenvswitch;hp=99e6dac63968aa2cac74179b695239eb2fd0619a;hpb=3570ff3853ceaf2d7f03752dbfa77a690d23c01e;p=nodemanager.git diff --git a/tools.py b/tools.py index 99e6dac..36754fc 100644 --- a/tools.py +++ b/tools.py @@ -1,6 +1,3 @@ -# $Id$ -# $URL$ - """A few things that didn't seem to fit anywhere else.""" import os, os.path @@ -10,6 +7,7 @@ import fcntl import errno import threading import subprocess +import shutil import logger @@ -111,7 +109,7 @@ The return value is the pid of the other running process, or None otherwise.""" def write_file(filename, do_write, **kw_args): """Write file atomically by opening a temporary file, using 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() @@ -148,7 +146,7 @@ def replace_file_with_string (target, new_contents, chmod=None, remove_if_empty= 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