Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
bbfa02a6
Commit
bbfa02a6
authored
1 year ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Informative error message when exflcalproxy is not available
parent
5e6f8db4
No related branches found
Branches containing commit
No related tags found
1 merge request
!885
Revised CalCat API
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/calcat_interface2.py
+19
-1
19 additions, 1 deletion
src/cal_tools/calcat_interface2.py
with
19 additions
and
1 deletion
src/cal_tools/calcat_interface2.py
+
19
−
1
View file @
bbfa02a6
...
@@ -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
=
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment