From 660bf74d42b5763994c79ee37cb9fc7216ee5a70 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 2 Nov 2016 10:41:47 -0400 Subject: [PATCH 1/2] fix missing conf file on first run --- lbrynet/conf.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index a236044f6..d3a960026 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -271,12 +271,15 @@ class Config(DefaultSettings): def update_settings_from_file(filename=None): filename = filename or settings.get_conf_filename() - try: - updates = load_settings(filename) - log.info("Loaded settings file: %s", updates) - settings.update(updates) - except OSError as ex: - log.info('%s: Failed to update settings from %s', ex, filename) + if os.path.isfile(filename): + try: + updates = load_settings(filename) + log.info("Loaded settings file: %s", updates) + settings.update(updates) + except OSError as ex: + log.info('%s: Failed to update settings from %s', ex, filename) + else: + log.warning("Invalid settings file path") settings_decoders = { @@ -290,8 +293,7 @@ settings_encoders = { } -def load_settings(path=None): - path = path or settings.get_conf_filename() +def load_settings(path): ext = os.path.splitext(path)[1] with open(path, 'r') as settings_file: data = settings_file.read() From c748572bf60d1843d8688abadaf476ad5c89db44 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 2 Nov 2016 11:32:46 -0400 Subject: [PATCH 2/2] feedback from job --- lbrynet/conf.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index d3a960026..807f3cb0e 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -271,15 +271,12 @@ class Config(DefaultSettings): def update_settings_from_file(filename=None): filename = filename or settings.get_conf_filename() - if os.path.isfile(filename): - try: - updates = load_settings(filename) - log.info("Loaded settings file: %s", updates) - settings.update(updates) - except OSError as ex: - log.info('%s: Failed to update settings from %s', ex, filename) - else: - log.warning("Invalid settings file path") + try: + updates = load_settings(filename) + log.info("Loaded settings file: %s", updates) + settings.update(updates) + except (IOError, OSError) as ex: + log.info('%s: Failed to update settings from %s', ex, filename) settings_decoders = {