Skip to content

Commit 8a5b779

Browse files
committed
Check response status
1 parent ab7bd7f commit 8a5b779

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

getBitstreams.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ def main():
103103

104104
# NOTE: expanding bitstreams to get the count, in case this is an item
105105
endpoint = baseURL+'/rest/handle/'+handle+'?expand=bitstreams'
106-
dsObject = requests.get(endpoint, headers=header, cookies=cookies, verify=verify, timeout=response_timeout).json()
106+
dsObject = requests.get(endpoint, headers=header, cookies=cookies, verify=verify, timeout=response_timeout)
107107
dsObject.raise_for_status() # ensure we notice bad responses
108+
dsObject = dsObject.json()
108109
if args.verbose: print dsObject
109110
dsObjectID = dsObject['uuid']
110111
# TODO: extend
@@ -131,7 +132,9 @@ def main():
131132
f.writerow(['bitstream']+['handle'])
132133

133134
for item in itemList:
134-
bitstreams = requests.get(baseURL+itemID+'/bitstreams', headers=header, cookies=cookies, verify=verify, timeout=response_timeout).json()
135+
bitstreams = requests.get(baseURL+itemID+'/bitstreams', headers=header, cookies=cookies, verify=verify, timeout=response_timeout)
136+
bitstreams.raise_for_status() # ensure we notice bad responses
137+
bitstreams = bitstreams.json()
135138
for bitstream in bitstreams:
136139
fileName = bitstream['name']
137140
fileName.replace('.pdf', '')

0 commit comments

Comments
 (0)