Skip to content
Snippets Groups Projects
Commit bbfa02a6 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Informative error message when exflcalproxy is not available

parent 5e6f8db4
No related branches found
No related tags found
1 merge request!885Revised CalCat API
...@@ -15,6 +15,10 @@ import requests ...@@ -15,6 +15,10 @@ import requests
from oauth2_xfel_client import Oauth2ClientBackend from oauth2_xfel_client import Oauth2ClientBackend
# Default address to connect to, only available internally
CALCAT_PROXY_URL = "http://exflcalproxy.desy.de:8080/"
class ModuleNameError(KeyError): class ModuleNameError(KeyError):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -158,7 +162,7 @@ global_client = None ...@@ -158,7 +162,7 @@ global_client = None
def get_client(): def get_client():
global global_client global global_client
if global_client is None: if global_client is None:
setup_client("http://exflcalproxy:8080/", None, None, None) setup_client(CALCAT_PROXY_URL, None, None, None)
return global_client return global_client
...@@ -193,6 +197,20 @@ def setup_client( ...@@ -193,6 +197,20 @@ def setup_client(
user_email=user_email, user_email=user_email,
) )
# Check we can connect to exflcalproxy
if oauth_client is None and base_url == CALCAT_PROXY_URL:
try:
# timeout=(connect_timeout, read_timeout)
global_client.get_request('me', timeout=(1, 5))
except requests.ConnectionError as e:
raise RuntimeError(
"Could not connect to calibration catalog proxy. This proxy allows "
"unauthenticated access inside the XFEL/DESY network. To look up "
"calibration constants from outside, you will need to create an Oauth "
"client ID & secret in the CalCat web interface. You will still not "
"be able to load constants without the constant store folder."
) from e
_default_caldb_root = ... _default_caldb_root = ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment