More flexible management for included config files paths

This commit is contained in:
Fabio Manganiello 2018-12-30 20:18:55 +01:00
parent 62045c2b5c
commit 09c1598829
2 changed files with 6 additions and 7 deletions

View file

@ -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):
"""

View file

@ -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():