def update_config(self, content, path):
old_file = six.BytesIO()
if files.exists(path, use_sudo=self.sudo):
fab.get(remote_path=path, local_path=old_file, use_sudo=self.sudo)
old_content = old_file.getvalue()
need_update = content != old_content
if need_update:
fabricio.move_file(
path_from=path,
path_to=path + '.backup',
sudo=self.sudo,
ignore_errors=True,
)
fab.put(six.BytesIO(content), path, use_sudo=self.sudo, mode='0644')
fabricio.log('{path} updated'.format(path=path))
else:
fabricio.log('{path} not changed'.format(path=path))
return need_update
评论列表
文章目录