config_file = os.path.join(config_dir, fname)
config_content = dict_get_join(config_files, fname)
logger.info('Write file: %s' % (config_file))
- with open(config_file, 'w') as f:
+ with open(config_file, 'w', encoding='utf-8') as f:
os.fchown(f.fileno(), uid, gid)
os.fchmod(f.fileno(), 0o600)
f.write(config_content)
fpath = os.path.join(data_dir_root, fname.lstrip(os.path.sep))
else:
fpath = os.path.join(data_dir_root, config_dir, fname)
- with open(fpath, 'w') as f:
+ with open(fpath, 'w', encoding='utf-8') as f:
os.fchown(f.fileno(), uid, gid)
os.fchmod(f.fileno(), 0o600)
f.write(content)
daemon_id=daemon_id
)
assert _open.call_args_list == [
- call('{}/etc/prometheus/prometheus.yml'.format(prefix), 'w'),
- call('{}/etc/prometheus/alerting/ceph_alerts.yml'.format(prefix), 'w'),
+ call('{}/etc/prometheus/prometheus.yml'.format(prefix), 'w',
+ encoding='utf-8'),
+ call('{}/etc/prometheus/alerting/ceph_alerts.yml'.format(prefix), 'w',
+ encoding='utf-8'),
]
assert call().__enter__().write('foo') in _open.mock_calls
assert call().__enter__().write('bar') in _open.mock_calls