refactor and rewrite for asyncio
This commit is contained in:
+5
-3
@@ -1,4 +1,5 @@
|
||||
"""Configuration loader and defaults for hbd."""
|
||||
import logging
|
||||
import os
|
||||
|
||||
try:
|
||||
@@ -14,6 +15,8 @@ DEFAULTS = {
|
||||
"logfile": "/var/log/heartbeat.log",
|
||||
"logfmt": "text",
|
||||
"pushsrv": "pushover",
|
||||
"pushover_token": "",
|
||||
"pushover_user": "",
|
||||
"interval": 20,
|
||||
"grace": 2,
|
||||
"dyndomains": ["wrede.org"],
|
||||
@@ -40,14 +43,13 @@ def load_config(path=None):
|
||||
if os.path.exists(path):
|
||||
if yaml:
|
||||
with open(path) as fh:
|
||||
data = yaml.safe_load(fh) or {}
|
||||
data = yaml.safe_load(fh)
|
||||
# only keep known keys
|
||||
for k, v in data.items():
|
||||
if k in cfg:
|
||||
cfg[k] = v
|
||||
else:
|
||||
# ignore unknown keys for now
|
||||
pass
|
||||
logging.warning("unknown config key %s in %s", k, path)
|
||||
else:
|
||||
# yaml not installed: do not attempt to parse; user must ensure defaults
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user