use json conf file if not given yml

This commit is contained in:
Jack 2016-11-05 14:23:48 -04:00
parent ab15074ae4
commit 297865902b

View file

@ -266,7 +266,7 @@ class Config(DefaultSettings):
return os.path.join(self.ensure_data_dir(), self.LOG_FILE_NAME)
def get_conf_filename(self):
return os.path.join(self.ensure_data_dir(), "daemon_settings.yml")
return get_settings_file_ext(self.ensure_data_dir())
def update_settings_from_file(filename=None):
@ -279,6 +279,17 @@ def update_settings_from_file(filename=None):
log.info('%s: Failed to update settings from %s', ex, filename)
def get_settings_file_ext(data_dir):
yml_path = os.path.join(data_dir, "daemon_settings.yml")
json_path = os.path.join(data_dir, "daemon_settings.json")
if os.path.isfile(yml_path):
return yml_path
elif os.path.isfile(json_path):
return json_path
else:
return yml_path
settings_decoders = {
'.json': json.loads,
'.yml': yaml.load