git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a little nicer
[nodemanager.git]
/
tools.py
diff --git
a/tools.py
b/tools.py
index
96df451
..
d8f216e
100644
(file)
--- a/
tools.py
+++ b/
tools.py
@@
-168,7
+168,8
@@
def write_temp_file(do_write, mode=None, uidgid=None):
return temporary_filename
return temporary_filename
-def replace_file_with_string(target, new_contents, chmod=None, remove_if_empty=False):
+def replace_file_with_string(target, new_contents,
+ chmod=None, remove_if_empty=False):
"""
Replace a target file with a new contents
checks for changes: does not do anything if previous state was already right
"""
Replace a target file with a new contents
checks for changes: does not do anything if previous state was already right
@@
-179,8
+180,8
@@
writes in a tmp file, which is then renamed (from sliverauth originally)
returns True if a change occurred, or the file is deleted
"""
try:
returns True if a change occurred, or the file is deleted
"""
try:
- with open(target) as f:
- current = f.read()
+ with open(target) as f
eed
:
+ current = f
eed
.read()
except:
current = ""
if current == new_contents:
except:
current = ""
if current == new_contents: