def move_file(remote, from_path, to_path, sudo=False):
- # need to stat the file first, to make sure we
- # maintain the same permissions
+ # need to stat the file first, to make sure we
+ # maintain the same permissions
args = []
if sudo:
args.append('sudo')
else:
log.info('removing line: {bad_line}'.format(bad_line=line))
- # get a temp file path on the remote host to write to,
- # we don't want to blow away the remote file and then have the
+ # get a temp file path on the remote host to write to,
+ # we don't want to blow away the remote file and then have the
# network drop out
temp_file_path = remote_mktemp(remote)
# then do a 'mv' to the actual file location
move_file(remote, temp_file_path, path)
-
+
def append_lines_to_file(remote, path, lines, sudo=False):
temp_file_path = remote_mktemp(remote)
-
+
data = get_file(remote, path, sudo)
# add the additional data and write it back out, using a temp file
- # in case of connectivity of loss, and then mv it to the
+ # in case of connectivity of loss, and then mv it to the
# actual desired location
data += lines
temp_file_path