Skip to content

Commit 673767a

Browse files
author
ehanson8
committed
updates
1 parent e139e74 commit 673767a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

resourcesWithNoBibNum.py

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

0 commit comments

Comments
 (0)