From 12557702dd2e7487038bfc8f3b2cf94ec398ca74 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 18 Dec 2018 18:46:07 +0100 Subject: [PATCH] - cfgfile should expand the home directory ~ - Don't fail hard if failed to create logs directory --- platypush/config/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index 9ba88369..e590ad77 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -83,7 +83,12 @@ class Config(object): if k == 'filename': logfile = os.path.expanduser(v) logdir = os.path.dirname(logfile) - os.makedirs(logdir, exist_ok=True) + try: + os.makedirs(logdir, exist_ok=True) + except Exception as e: + print('Unable to create logs directory {}: {}'.format( + logdir, str(e))) + v = logfile del logging_config['stream'] elif k == 'level': @@ -111,10 +116,9 @@ class Config(object): def _read_config_file(self, cfgfile): - if not os.path.isabs(cfgfile): - cfgfile = os.path.join(os.path.dirname(self._cfgfile), cfgfile) - + cfgfile = os.path.abspath(os.path.expanduser(cfgfile)) config = {} + with open(cfgfile, 'r') as fp: file_config = yaml.safe_load(fp)