Merge branch 'configpath' into 'master'

config refactor from os.environ to pathlib

See merge request sum7/ejabberd-tools!8
This commit is contained in:
nico 2020-09-18 21:42:59 +02:00
commit 126ac02f56
1 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys import sys
from os import environ
from pathlib import Path from pathlib import Path
from ruamel.yaml import YAML from ruamel.yaml import YAML
@ -13,11 +12,12 @@ class Config:
def __init__(self): def __init__(self):
# class variables # class variables
self.content = None self.content = None
self.conf_file = Path("/etc/ejabberd-metrics.yml")
# dev config overwrite # select config file
if environ.get("ejabberd_metrics_dev"): if Path.exists(Path("config.yml")):
self.conf_file = Path("config.yml") self.conf_file = Path("config.yml")
else:
self.conf_file = Path("/etc/ejabberd-metrics.yml")
# read config file # read config file
self._read() self._read()