Skip to content

Commit

Permalink
Added custom_file argument in config.load_conf.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Delle Cave committed Dec 15, 2019
1 parent 8296a10 commit db54a27
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
python-dwho (0.3.16) unstable; urgency=medium

* Added custom_file argument in config.load_conf.

-- Adrien DELLE CAVE (Decryptus) <adc@doowan.net> Sun, 15 Dec 2019 11:07:47 +0100

python-dwho (0.3.15) unstable; urgency=medium

* Fixed notifier log for subproc.
Expand Down
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.15
0.3.16
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.15
0.3.16
19 changes: 15 additions & 4 deletions dwho/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def stop(signum, stack_frame): # pylint: disable=unused-argument
for t in DWHO_THREADS:
t()

def get_server_id(conf):
def get_server_id(conf = None):
server_id = getfqdn()

if 'general' in conf \
if isinstance(conf, dict) \
and 'general' in conf \
and conf['general'].get('server_id'):
server_id = conf['general']['server_id']

Expand Down Expand Up @@ -123,7 +124,7 @@ def parse_conf(conf, load_creds = False):

return conf

def load_conf(xfile, options = None, parse_conf_func = None, load_creds = False, envvar = None):
def load_conf(xfile, options = None, parse_conf_func = None, load_creds = False, envvar = None, custom_file = None):
signal.signal(signal.SIGTERM, stop)
signal.signal(signal.SIGINT, stop)

Expand All @@ -133,7 +134,17 @@ def load_conf(xfile, options = None, parse_conf_func = None, load_creds = False,
with open(xfile, 'r') as f:
conf = helpers.load_yaml(f)

conf['_config_directory'] = os.path.dirname(os.path.abspath(xfile))
config_directory = os.path.dirname(os.path.abspath(xfile))
conf['_config_directory'] = config_directory

if custom_file:
conf = helpers.merge(
helpers.load_conf_yaml_file(
custom_file,
config_directory),
conf)

conf['_config_directory'] = config_directory
elif envvar and os.environ.get(envvar):
c = StringIO(os.environ[envvar])
conf = helpers.load_yaml(c.getvalue())
Expand Down
4 changes: 2 additions & 2 deletions setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: dwho
author: Adrien Delle Cave
author_email: pypi@doowan.net
copyright: '2019 Adrien Delle Cave'
release: '0.3.15'
version: '0.3.15'
release: '0.3.16'
version: '0.3.16'
license: License GPL-3
url: https://github.com/decryptus/dwho
python_requires:
Expand Down

0 comments on commit db54a27

Please sign in to comment.