From 09c1598829cd70265e5075ec0e6470ac29125611 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 30 Dec 2018 20:18:55 +0100 Subject: [PATCH] More flexible management for included config files paths --- platypush/__init__.py | 6 +++--- platypush/config/__init__.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/platypush/__init__.py b/platypush/__init__.py index 26a49f89d..82a234303 100644 --- a/platypush/__init__.py +++ b/platypush/__init__.py @@ -68,13 +68,13 @@ class Daemon: f.write(str(os.getpid())) self.config_file = config_file + Config.init(self.config_file) + logging.basicConfig(**Config.get('logging')) + self.event_processor = EventProcessor() self.requests_to_process = requests_to_process self.processed_requests = 0 - Config.init(self.config_file) - logging.basicConfig(**Config.get('logging')) - @classmethod def build_from_cmdline(cls, args): """ diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index 90075b7fe..b902bbef0 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -117,9 +117,8 @@ class Config(object): def _read_config_file(self, cfgfile): - cfgfile_dir = os.path.expanduser(os.path.dirname(self._cfgfile)) - if not os.path.isabs(cfgfile): - cfgfile = os.path.join(cfgfile_dir, os.path.basename(cfgfile)) + cfgfile_dir = os.path.dirname(os.path.abspath( + os.path.expanduser(cfgfile))) config = {} @@ -135,7 +134,7 @@ class Config(object): for include_file in include_files: if not os.path.isabs(include_file): include_file = os.path.join(cfgfile_dir, include_file) - self._included_files.add(os.path.abspath(include_file)) + self._included_files.add(include_file) included_config = self._read_config_file(include_file) for incl_section in included_config.keys():