fix missing conf file on first run
This commit is contained in:
parent
4db3be345b
commit
660bf74d42
1 changed files with 10 additions and 8 deletions
|
@ -271,12 +271,15 @@ class Config(DefaultSettings):
|
||||||
|
|
||||||
def update_settings_from_file(filename=None):
|
def update_settings_from_file(filename=None):
|
||||||
filename = filename or settings.get_conf_filename()
|
filename = filename or settings.get_conf_filename()
|
||||||
try:
|
if os.path.isfile(filename):
|
||||||
updates = load_settings(filename)
|
try:
|
||||||
log.info("Loaded settings file: %s", updates)
|
updates = load_settings(filename)
|
||||||
settings.update(updates)
|
log.info("Loaded settings file: %s", updates)
|
||||||
except OSError as ex:
|
settings.update(updates)
|
||||||
log.info('%s: Failed to update settings from %s', ex, filename)
|
except OSError as ex:
|
||||||
|
log.info('%s: Failed to update settings from %s', ex, filename)
|
||||||
|
else:
|
||||||
|
log.warning("Invalid settings file path")
|
||||||
|
|
||||||
|
|
||||||
settings_decoders = {
|
settings_decoders = {
|
||||||
|
@ -290,8 +293,7 @@ settings_encoders = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def load_settings(path=None):
|
def load_settings(path):
|
||||||
path = path or settings.get_conf_filename()
|
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
with open(path, 'r') as settings_file:
|
with open(path, 'r') as settings_file:
|
||||||
data = settings_file.read()
|
data = settings_file.read()
|
||||||
|
|
Loading…
Reference in a new issue