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__":
|
||||
import os
|
||||
import json
|
||||
from config import Config
|
||||
|
||||
# load config
|
||||
path = os.path.dirname(__file__)
|
||||
with open("/".join([path, "config.json"]), "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
config = Config()
|
||||
|
||||
url = config['url'] if "url" in config else "http://[::1]:5280/api"
|
||||
login = config['login'] if "login" in config else None
|
||||
api = config['api'] if "api" in config else "rest"
|
||||
# credentials and parameters
|
||||
url = config.get('url', default='http://localhost:5280/api')
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue