From c9bd2b19c992fd9328cb4b79ea2b14500b9c3646 Mon Sep 17 00:00:00 2001
From: Thomas Kluyver <thomas.kluyver@xfel.eu>
Date: Thu, 17 Nov 2022 17:54:01 +0100
Subject: [PATCH] Fix names in loaded config

---
 calparrot/__main__.py | 10 ++++++----
 calparrot/proxy.py    |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/calparrot/__main__.py b/calparrot/__main__.py
index 097809d..3766f8c 100644
--- a/calparrot/__main__.py
+++ b/calparrot/__main__.py
@@ -22,11 +22,13 @@ def main():
     logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
 
 
+    print("All config:", restful_config)
     calcat_cfg = restful_config.get('calcat', {})
-    calcat_cfg.setdefault('base_url', 'http://exflcalproxy:8080/')
-    calcat_cfg.setdefault('use_oauth2', False)
-    log.info("Upstream is %s (with%s Oauth)", calcat_cfg['base_url'],
-             '' if calcat_cfg['use_oauth2'] else 'out')
+    print("Loaded config:", calcat_cfg)
+    calcat_cfg.setdefault('base-api-url', 'http://exflcalproxy:8080/api/')
+    calcat_cfg.setdefault('use-oauth2', False)
+    log.info("Upstream is %s (with%s Oauth)", calcat_cfg['base-api-url'],
+             '' if calcat_cfg['use-oauth2'] else 'out')
 
     app = ProxyApp(calcat_cfg, args.db)
     log.info("CalParrot will serve constant queries on http://127.0.0.1:%d", app.port)
diff --git a/calparrot/proxy.py b/calparrot/proxy.py
index dcde722..851891f 100644
--- a/calparrot/proxy.py
+++ b/calparrot/proxy.py
@@ -189,9 +189,9 @@ class ProxyApp:
 
     def __init__(self, creds, db_path='calparrot.sqlite'):
         self.response_store = ResponsesDB(db_path)
-        base_url = creds['base_url'].rstrip('/')  # e.g. https://in.xfel.eu/calibration
+        base_url = creds['base-api-url'].rstrip('/')  # e.g. https://in.xfel.eu/calibration
 
-        if creds['use_oauth2']:
+        if creds['use-oauth2']:
             self.client = XFELOauthClient(
                 creds['client_id'],
                 creds['client_secret'],
-- 
GitLab