X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools.py;h=36754fc9fc45547c766555d72fcce55107d1270e;hb=cabdd946793b35b2fcaff5ee2ffec4a1644d8391;hp=a0fbe56516bd25d9e0178e71f61861cfde47e5a5;hpb=854fdfe526baa82adf31f14cac8a62223b310050;p=nodemanager.git diff --git a/tools.py b/tools.py index a0fbe56..36754fc 100644 --- a/tools.py +++ b/tools.py @@ -7,6 +7,7 @@ import fcntl import errno import threading import subprocess +import shutil import logger @@ -108,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() @@ -145,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