config handeling
* add proper configuration handeling to the metrics class
This commit is contained in:
parent
1a3782ce97
commit
634ba02e76
|
@ -355,19 +355,19 @@ class EjabberdMetrics:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
from config import Config
|
||||||
|
|
||||||
# load config
|
# load config
|
||||||
path = os.path.dirname(__file__)
|
config = Config()
|
||||||
with open("/".join([path, "config.json"]), "r", encoding="utf-8") as f:
|
|
||||||
config = json.load(f)
|
|
||||||
|
|
||||||
url = config['url'] if "url" in config else "http://[::1]:5280/api"
|
# credentials and parameters
|
||||||
login = config['login'] if "login" in config else None
|
url = config.get('url', default='http://localhost:5280/api')
|
||||||
api = config['api'] if "api" in config else "rest"
|
login = config.get('login', default=None)
|
||||||
|
api = config.get('api', default='rest')
|
||||||
|
|
||||||
metric = EjabberdMetrics(url, login=login, api=api)
|
# init handler
|
||||||
|
metrics = EjabberdMetrics(url, login, api)
|
||||||
|
|
||||||
data = metric.get_all()
|
data = metrics.get_all()
|
||||||
print(json.dumps(data, indent=True))
|
print(json.dumps(data, indent=True))
|
||||||
|
|
Loading…
Reference in New Issue