aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xejabberdrpc.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/ejabberdrpc.py b/ejabberdrpc.py
index 7de19e6..6a34cd0 100755
--- a/ejabberdrpc.py
+++ b/ejabberdrpc.py
@@ -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)
-
- data = metric.get_all()
+ # init handler
+ metrics = EjabberdMetrics(url, login, api)
+
+ data = metrics.get_all()
print(json.dumps(data, indent=True))