提交 68cd3465 编写于 作者: L Lukáš Doktor

avocado.settings: Don't fail when user can't write user-config

The user-config location ("~/.config/avocado.conf") might not be
writable by users (usually when executing in docker without user
home-dir). Let's use the file if available, but don't fail in case we
fail to produce it.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 48da2b98
......@@ -198,10 +198,16 @@ class Settings(object):
for extra_file in glob.glob(os.path.join(_config_dir_system_extra, '*.conf')):
self.process_config_path(extra_file)
if not config_local:
path.init_dir(_config_dir_local)
with open(config_path_local, 'w') as config_local_fileobj:
config_local_fileobj.write('# You can use this file to override configuration values from '
'%s and %s\n' % (config_path_system, _config_dir_system_extra))
try:
path.init_dir(_config_dir_local)
with open(config_path_local, 'w') as config_local_fileobj:
content = ("# You can use this file to override "
"configuration values from '%s and %s\n"
% (config_path_system,
_config_dir_system_extra))
config_local_fileobj.write(content)
except IOError: # Some users can't write it (docker)
pass
else:
self.process_config_path(config_path_local)
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册