Skip to content

Commit 6c97416

Browse files
author
ehanson8
committed
updates
1 parent c90246f commit 6c97416

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

getTopContainers.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import json
2+
import requests
3+
import secrets
4+
import time
5+
6+
startTime = time.time()
7+
8+
baseURL = secrets.baseURL
9+
user = secrets.user
10+
password = secrets.password
11+
12+
auth = requests.post(baseURL + '/users/'+user+'/login?password='+password).json()
13+
session = auth["session"]
14+
headers = {'X-ArchivesSpace-Session':session, 'Content_Type':'application/json'}
15+
print 'authenticated'
16+
17+
endpoint = '/repositories/3/top_containers?all_ids=true'
18+
19+
ids = requests.get(baseURL + endpoint, headers=headers).json()
20+
21+
records = []
22+
for id in ids:
23+
endpoint = '/repositories/3/top_containers/'+str(id)
24+
output = requests.get(baseURL + endpoint, headers=headers).json()
25+
records.append(output)
26+
27+
f=open('topContainers.json', 'w')
28+
json.dump(records, f)
29+
f.close()
30+
31+
elapsedTime = time.time() - startTime
32+
m, s = divmod(elapsedTime, 60)
33+
h, m = divmod(m, 60)
34+
print 'Total script run time: ', '%d:%02d:%02d' % (h, m, s)

0 commit comments

Comments
 (0)