BookOps-CAT / bookops-worldcat

BookOps WorldCat Metadata API wrapper
https://bookops-cat.github.io/bookops-worldcat/
MIT License
35 stars 7 forks source link

Handling of the HTTP 206 code #32

Closed klinga closed 2 years ago

klinga commented 4 years ago

figure out handling of 206 code responses in MetadataSession:

klinga commented 2 years ago

example of exception while hitting search endpoint in NightShift:

nightshift-2022-02-08 13:08:59,909-worldcat.py-244-ERROR-WorldcatSessionError. Aborting. ERROR:nightshift:WorldcatSessionError. Aborting. Traceback (most recent call last): File "C:\Users[name]\AppData\Local\pypoetry\Cache\virtualenvs\nightshift-Veb3c4LN-py3.9\lib\site-packages\bookops_worldcat\metadata_api.py", line 922, in search_brief_bibs raise WorldcatRequestError(error_msg) bookops_worldcat.errors.WorldcatRequestError: Web service returned 206 error: {"numberOfRecords":1,"briefRecords":[{"oclcNumber":"946535795","title":"Out of the dying pan","creator":"Li nda Reilly","date":"2016","machineReadableDate":"2016","language":"eng","generalFormat":"Book","specificFormat":"Digital","publisher":"Berkley Books","publicationPlace":"New York","isbn s":["9780698154889","0698154886"],"mergedOclcNumbers":["936630584","945790582"],"catalogingInfo":{"catalogingAgency":"RECBK","catalogingLanguage":"eng","levelOfCataloging":"M","transcri bingAgency":"RECBK"}}]}; https://americas.metadata.api.oclc.org/worldcat/search/v1/brief-bibs?q=sn%3DEEF41EFD-3F5C-45DA-AE3E-27C622C32ED2+NOT+lv%3A3&inCatalogLanguage=eng&itemType=book& itemSubType=book-digital&orderBy=mostWidelyHeld&limit=1

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users[name]\github\nightshift\nightshift\bot.py", line 121, in main(sys.argv[1:]) # pragma: no cover File "C:\Users[name]\github\nightshift\nightshift\bot.py", line 114, in main run(env=pargs.environment) File "C:\Users[name]\github\nightshift\nightshift\bot.py", line 80, in run manager.process_resources() File "C:\Users[name]\GitHub\NightShift\nightshift\manager.py", line 70, in process_resources tasks.get_worldcat_brief_bib_matches(db_session, library, resources) File "C:\Users[name]\GitHub\NightShift\nightshift\tasks.py", line 119, in get_worldcat_brief_bib_matches for resource, response in results: File "C:\Users[name]\GitHub\NightShift\nightshift\comms\worldcat.py", line 222, in get_brief_bibs response = self.session.search_brief_bibs( File "C:\Users[name]\AppData\Local\pypoetry\Cache\virtualenvs\nightshift-Veb3c4LN-py3.9\lib\site-packages\bookops_worldcat\metadata_api.py", line 924, in search_brief_bibs raise WorldcatRequestError(exc) bookops_worldcat.errors.WorldcatRequestError: Web service returned 206 error: {"numberOfRecords":1,"briefRecords":[{"oclcNumber":"946535795","title":"Out of the dying pan","creator":"Li nda Reilly","date":"2016","machineReadableDate":"2016","language":"eng","generalFormat":"Book","specificFormat":"Digital","publisher":"Berkley Books","publicationPlace":"New York","isbn s":["9780698154889","0698154886"],"mergedOclcNumbers":["936630584","945790582"],"catalogingInfo":{"catalogingAgency":"RECBK","catalogingLanguage":"eng","levelOfCataloging":"M","transcri bingAgency":"RECBK"}}]}; https://americas.metadata.api.oclc.org/worldcat/search/v1/brief-bibs?q=sn%3DEEF41EFD-3F5C-45DA-AE3E-27C622C32ED2+NOT+lv%3A3&inCatalogLanguage=eng&itemType=book& itemSubType=book-digital&orderBy=mostWidelyHeld&limit=1

klinga commented 2 years ago

done https://github.com/BookOps-CAT/bookops-worldcat/pull/53