Skip to content

Commit

Permalink
Put a check for files.
Browse files Browse the repository at this point in the history
The script was throwing an error. CRITICAL: NameError("name 'files' is not defined",)
  • Loading branch information
themiszamani authored Apr 12, 2022
1 parent 0d83d90 commit c1facd3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions check_b2share.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ def get_dict_from_url(url, verify_tls_cert=False, verbosity=False):

rec_with_files_url = None
for hit in search_results['hits']['hits']:
# Check if there are files in the record
if len(hit['files']) > 0:
# NTS: Could throw KeyError if there is something
# seriously wrong or B2SHARE REST API responses have
# changed.
rec_with_files_url = hit['links']['self']
break
if 'files' in hit:
# Check if there are files in the record
if len(hit['files']) > 0:
# NTS: Could throw KeyError if there is something
# seriously wrong or B2SHARE REST API responses have
# changed.
rec_with_files_url = hit['links']['self']
break

if rec_with_files_url:

Expand Down

0 comments on commit c1facd3

Please sign in to comment.