From 714548b0c7d1813c681a5484bbde8ce12e9efedc Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 18 Sep 2020 16:42:36 +0200 Subject: [PATCH 1/2] refactor os.environ to pathlib * config.py should use the smaller lib to determine which config to load --- config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index d4a7097..b99708f 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys -from os import environ from pathlib import Path from ruamel.yaml import YAML @@ -13,11 +12,12 @@ class Config: def __init__(self): # class variables self.content = None - self.conf_file = Path("/etc/ejabberd-metrics.yml") - # dev config overwrite - if environ.get("ejabberd_metrics_dev"): + # select config file + if Path.exists(Path("config.yml")): self.conf_file = Path("config.yml") + else: + self.conf_file = Path("/etc/ejabberd-metrics.yml") # read config file self._read() -- 2.44.0 From a9e9f2e174f81979e40f42a6440159f2ee1e2ed4 Mon Sep 17 00:00:00 2001 From: genofire Date: Sat, 26 Sep 2020 22:08:01 +0200 Subject: [PATCH 2/2] pathlib config path - short version --- config.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index b99708f..ee72f1c 100644 --- a/config.py +++ b/config.py @@ -14,9 +14,8 @@ class Config: self.content = None # select config file - if Path.exists(Path("config.yml")): - self.conf_file = Path("config.yml") - else: + self.conf_file = Path("config.yml") + if not Path.exists(self.conf_file): self.conf_file = Path("/etc/ejabberd-metrics.yml") # read config file -- 2.44.0