-
Notifications
You must be signed in to change notification settings - Fork 23
/
console.py
28 lines (24 loc) · 966 Bytes
/
console.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from dspace_rest_client.client import DSpaceClient
# Import models as needed
#from dspace_rest_client.models import Community, Collection, Item, Bundle, Bitstream
import code
import os
# The DSpace client will look for the same environment variables, but we can also look for them here explicitly
# and as an example
url = 'http://localhost:8080/server/api'
if 'DSPACE_API_ENDPOINT' in os.environ:
url = os.environ['DSPACE_API_ENDPOINT']
username = '[email protected]'
if 'DSPACE_API_USERNAME' in os.environ:
username = os.environ['DSPACE_API_USERNAME']
password = 'password'
if 'DSPACE_API_PASSWORD' in os.environ:
password = os.environ['DSPACE_API_PASSWORD']
# Instantiate DSpace client
d = DSpaceClient(api_endpoint=url, username=username, password=password)
# Authenticate against the DSpace client
authenticated = d.authenticate()
if not authenticated:
print(f'Error logging in! Giving up.')
exit(1)
code.interact(local=locals())