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
76e157b8
Commit
76e157b8
authored
8 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
logout and token-test added
parent
366e4eb5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/python/PyBis/pybis/pybis.py
+20
-14
20 additions, 14 deletions
src/python/PyBis/pybis/pybis.py
src/python/pybis/tests/test_openbis.py
+7
-1
7 additions, 1 deletion
src/python/pybis/tests/test_openbis.py
with
27 additions
and
15 deletions
src/python/PyBis/pybis/pybis.py
+
20
−
14
View file @
76e157b8
...
@@ -92,9 +92,8 @@ class Openbis:
...
@@ -92,9 +92,8 @@ class Openbis:
self
.
as_port
=
'
:20000
'
self
.
as_port
=
'
:20000
'
self
.
ds_port
=
'
:20001
'
self
.
ds_port
=
'
:20001
'
self
.
token
=
None
self
.
token
=
None
self
.
v3_as_gi
=
'
/openbis/openbis/rmi-application-server-v3.json
'
self
.
v3_as
=
'
/openbis/openbis/rmi-application-server-v3.json
'
self
.
v1_as_gi
=
'
/openbis/openbis/rmi-general-information-v1.json
'
self
.
v1_as
=
'
/openbis/openbis/rmi-general-information-v1.json
'
self
.
v1_ds_screening
=
'
/rmi-datastore-server-screening-api-v1.json
'
def
token
(
self
):
def
token
(
self
):
if
self
.
token
is
None
:
if
self
.
token
is
None
:
...
@@ -121,9 +120,8 @@ class Openbis:
...
@@ -121,9 +120,8 @@ class Openbis:
"
id
"
:
"
1
"
,
"
id
"
:
"
1
"
,
"
jsonrpc
"
:
"
2.0
"
"
jsonrpc
"
:
"
2.0
"
}
}
resp
=
requests
.
post
(
self
.
host
+
self
.
v3_as_gi
,
json
.
dumps
(
logout_request
))
resp
=
self
.
post_request
(
self
.
v3_as
,
logout_request
)
if
resp
.
ok
:
return
resp
self
.
token
=
None
def
login
(
self
,
username
=
'
openbis_test_js
'
,
password
=
'
password
'
,
store_credentials
=
False
):
def
login
(
self
,
username
=
'
openbis_test_js
'
,
password
=
'
password
'
,
store_credentials
=
False
):
...
@@ -140,7 +138,7 @@ class Openbis:
...
@@ -140,7 +138,7 @@ class Openbis:
"
id
"
:
"
1
"
,
"
id
"
:
"
1
"
,
"
jsonrpc
"
:
"
2.0
"
"
jsonrpc
"
:
"
2.0
"
}
}
result
=
self
.
post_request
(
self
.
v3_as
_gi
,
login_request
)
result
=
self
.
post_request
(
self
.
v3_as
,
login_request
)
self
.
token
=
result
self
.
token
=
result
...
@@ -151,9 +149,17 @@ class Openbis:
...
@@ -151,9 +149,17 @@ class Openbis:
:return: Return True if the token is valid, False if it is not valid.
:return: Return True if the token is valid, False if it is not valid.
"""
"""
if
not
self
.
token
:
request
=
{
return
False
"
method
"
:
"
isSessionActive
"
,
"
params
"
:
[
self
.
token
],
"
id
"
:
"
1
"
,
"
jsonrpc
"
:
"
2.0
"
}
resp
=
self
.
post_request
(
self
.
v1_as
,
request
)
print
(
resp
)
return
resp
def
get_dataset
(
self
,
permid
):
def
get_dataset
(
self
,
permid
):
...
@@ -209,7 +215,7 @@ class Openbis:
...
@@ -209,7 +215,7 @@ class Openbis:
"
jsonrpc
"
:
"
2.0
"
"
jsonrpc
"
:
"
2.0
"
}
}
resp
=
self
.
post_request
(
self
.
v3_as
_gi
,
dataset_request
)
resp
=
self
.
post_request
(
self
.
v3_as
,
dataset_request
)
if
resp
is
not
None
:
if
resp
is
not
None
:
for
permid
in
resp
:
for
permid
in
resp
:
return
DataSet
(
self
,
permid
,
resp
[
permid
])
return
DataSet
(
self
,
permid
,
resp
[
permid
])
...
@@ -279,11 +285,11 @@ class Openbis:
...
@@ -279,11 +285,11 @@ class Openbis:
}
}
}
}
],
],
"
id
"
:
"
1
"
,
"
id
"
:
ident
,
"
jsonrpc
"
:
"
2.0
"
"
jsonrpc
"
:
"
2.0
"
}
}
resp
=
requests
.
post
(
self
.
host
+
self
.
v3_as
_gi
,
json
.
dumps
(
sample_request
))
resp
=
requests
.
post
(
self
.
host
+
self
.
v3_as
,
json
.
dumps
(
sample_request
))
if
resp
.
ok
:
if
resp
.
ok
:
data
=
resp
.
json
()
data
=
resp
.
json
()
if
"
error
"
in
data
:
if
"
error
"
in
data
:
...
@@ -329,7 +335,7 @@ class DataSet(Openbis):
...
@@ -329,7 +335,7 @@ class DataSet(Openbis):
self
.
openbis
=
openbis_obj
self
.
openbis
=
openbis_obj
self
.
permid
=
permid
self
.
permid
=
permid
self
.
data
=
data
self
.
data
=
data
self
.
v1_ds
_api
=
'
/datastore_server/rmi-dss-api-v1.json
'
self
.
v1_ds
=
'
/datastore_server/rmi-dss-api-v1.json
'
self
.
downloadUrl
=
self
.
data
[
'
dataStore
'
][
'
downloadUrl
'
]
self
.
downloadUrl
=
self
.
data
[
'
dataStore
'
][
'
downloadUrl
'
]
...
@@ -363,7 +369,7 @@ class DataSet(Openbis):
...
@@ -363,7 +369,7 @@ class DataSet(Openbis):
"
id
"
:
"
1
"
"
id
"
:
"
1
"
}
}
resp
=
requests
.
post
(
self
.
downloadUrl
+
self
.
v1_ds
_api
,
json
.
dumps
(
request
))
resp
=
requests
.
post
(
self
.
downloadUrl
+
self
.
v1_ds
,
json
.
dumps
(
request
))
if
resp
.
ok
:
if
resp
.
ok
:
if
'
error
'
in
resp
.
json
():
if
'
error
'
in
resp
.
json
():
...
...
This diff is collapsed.
Click to expand it.
src/python/pybis/tests/test_openbis.py
+
7
−
1
View file @
76e157b8
...
@@ -3,7 +3,13 @@ from pybis import DataSet
...
@@ -3,7 +3,13 @@ from pybis import DataSet
from
pybis
import
Openbis
from
pybis
import
Openbis
def
test_token
(
openbis_instance
):
def
test_token
(
openbis_instance
):
assert
openbis_instance
.
token
is
not
None
assert
openbis_instance
.
host
is
not
None
new_instance
=
Openbis
(
openbis_instance
.
host
)
new_instance
.
login
()
assert
new_instance
.
token
is
not
None
assert
new_instance
.
is_token_valid
()
is
True
new_instance
.
logout
()
assert
new_instance
.
is_token_valid
()
is
False
def
test_get_samples_by_id
(
openbis_instance
):
def
test_get_samples_by_id
(
openbis_instance
):
...
...
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