Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
92b506d4
Commit
92b506d4
authored
8 years ago
by
Chandrasekhar Ramakrishnan
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-3554: Allow setting of path where token is saved. Path defaults to current users home dir.
parent
6eed63e0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/python/PyBis/pybis/pybis.py
+22
-8
22 additions, 8 deletions
src/python/PyBis/pybis/pybis.py
with
22 additions
and
8 deletions
src/python/PyBis/pybis/pybis.py
+
22
−
8
View file @
92b506d4
...
...
@@ -103,26 +103,40 @@ class Openbis:
self
.
v3_as
=
'
/openbis/openbis/rmi-application-server-v3.json
'
self
.
v1_as
=
'
/openbis/openbis/rmi-general-information-v1.json
'
self
.
verify_certificates
=
verify_certificates
self
.
token
=
None
self
.
initialize_token
()
self
.
token_filename
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"
~
"
),
'
.pybis
'
,
self
.
hostname
+
'
.token
'
)
try
:
with
open
(
self
.
token_filename
)
as
f
:
def
initialize_token
(
self
):
"""
Read the token from the cache, and set the token ivar to it, if there, otherwise None.
"""
token_path
=
self
.
token_path
()
if
not
os
.
path
.
exists
(
token_path
):
self
.
token
=
None
return
try
:
with
open
(
token_path
)
as
f
:
self
.
token
=
f
.
read
()
if
not
self
.
is_token_valid
():
self
.
token
=
None
os
.
remove
(
self
.
token_
filename
)
os
.
remove
(
token_
path
)
except
FileNotFoundError
:
self
.
token
=
None
def
token
(
self
):
if
self
.
token
is
None
:
raise
ValueError
(
'
no valid session available
'
)
def
save_token
(
self
):
os
.
makedirs
(
os
.
path
.
dirname
(
self
.
token_filename
),
exist_ok
=
True
)
with
open
(
self
.
token_filename
,
'
w
'
)
as
f
:
def
token_path
(
self
,
parent_folder
=
None
):
"""
Return the path to the token file.
"""
if
parent_folder
is
None
:
parent_folder
=
os
.
path
.
expanduser
(
"
~
"
)
path
=
os
.
path
.
join
(
parent_folder
,
'
.pybis
'
,
self
.
hostname
+
'
.token
'
)
return
path
def
save_token
(
self
,
parent_folder
=
None
):
token_path
=
self
.
token_path
(
parent_folder
)
os
.
makedirs
(
os
.
path
.
dirname
(
token_path
),
exist_ok
=
True
)
with
open
(
token_path
,
'
w
'
)
as
f
:
f
.
write
(
self
.
token
)
...
...
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