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
10b5b106
Commit
10b5b106
authored
6 months ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Allow setting a global default for caldb_root
parent
2ca248e8
No related branches found
Branches containing commit
No related tags found
1 merge request
!1068
Public API to set caldb_root (option 2)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cal_tools/calcat_interface2.py
+3
-0
3 additions, 0 deletions
src/cal_tools/calcat_interface2.py
src/cal_tools/restful_config.py
+9
-18
9 additions, 18 deletions
src/cal_tools/restful_config.py
with
12 additions
and
18 deletions
src/cal_tools/calcat_interface2.py
+
3
−
0
View file @
10b5b106
...
@@ -214,6 +214,9 @@ def setup_client(
...
@@ -214,6 +214,9 @@ def setup_client(
_default_caldb_root
=
None
_default_caldb_root
=
None
def
set_default_caldb_root
(
p
:
Path
):
global
_default_caldb_root
_default_caldb_root
=
p
def
_get_default_caldb_root
():
def
_get_default_caldb_root
():
global
_default_caldb_root
global
_default_caldb_root
...
...
This diff is collapsed.
Click to expand it.
src/cal_tools/restful_config.py
+
9
−
18
View file @
10b5b106
...
@@ -50,25 +50,16 @@ def extra_calibration_client():
...
@@ -50,25 +50,16 @@ def extra_calibration_client():
from
cal_tools
import
calcat_interface2
from
cal_tools
import
calcat_interface2
calcat_config
=
restful_config
.
get
(
'
calcat
'
)
calcat_config
=
restful_config
.
get
(
'
calcat
'
)
user_id
=
user_secret
=
None
if
calcat_config
[
'
use-oauth2
'
]:
if
calcat_config
[
'
use-oauth2
'
]:
from
oauth2_xfel_client
import
Oauth2ClientBackend
user_id
,
user_secret
=
calcat_config
[
'
user-id
'
],
calcat_config
[
'
user-secret
'
]
oauth_client
=
Oauth2ClientBackend
(
client_id
=
calcat_config
[
'
user-id
'
],
client_secret
=
calcat_config
[
'
user-secret
'
],
token_url
=
calcat_config
[
'
token-url
'
],
scope
=
''
,
)
else
:
oauth_client
=
None
if
calcat_config
[
'
caldb-root
'
]:
calcat_interface2
.
setup_client
(
calcat_interface2
.
_default_caldb_root
=
Path
(
calcat_config
[
'
caldb-root
'
])
calcat_config
[
'
base-api-url
'
],
client_id
=
user_id
,
client
=
calcat_interface2
.
CalCatAPIClient
(
client_secret
=
user_secret
,
base_api_url
=
calcat_config
[
'
base-api-url
'
],
oauth_client
=
oauth_client
,
user_email
=
calcat_config
[
'
user-email
'
],
user_email
=
calcat_config
[
'
user-email
'
],
)
)
if
calcat_config
[
'
caldb-root
'
]:
calcat_interface2
.
global_client
=
client
calcat_interface2
.
set_default_caldb_root
(
Path
(
calcat_config
[
'
caldb-root
'
]))
return
client
return
calcat_interface2
.
get_
client
()
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