forked from the-library-code/dspace-rest-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.py
More file actions
27 lines (21 loc) · 846 Bytes
/
console.py
File metadata and controls
27 lines (21 loc) · 846 Bytes
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
import code
import os
import sys
from dspace_rest_client.client import DSpaceClient
# Import models as needed
#from dspace_rest_client.models import Community, Collection, Item, Bundle, Bitstream
DEFAULT_URL = 'http://localhost:8080/server/api'
DEFAULT_USERNAME = 'username@test.system.edu'
DEFAULT_PASSWORD = 'password'
# Configuration from environment variables
URL = os.environ.get('DSPACE_API_ENDPOINT', DEFAULT_URL)
USERNAME = os.environ.get('DSPACE_API_USERNAME', DEFAULT_USERNAME)
PASSWORD = os.environ.get('DSPACE_API_PASSWORD', DEFAULT_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('Error logging in! Giving up.')
sys.exit(1)
code.interact(local=locals())