Skip to content

Commit c0a6a41

Browse files
author
Benjamin Moody
committed
get_annotators: use _get_url in place of requests.get.
Note that this will handle errors (e.g. a file that we are not authorized to access) and raise an exception, rather than trying to parse the error document. Previously, 404 errors were handled, but other types of errors were not.
1 parent 3cec71f commit c0a6a41

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

wfdb/io/download.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,16 @@ def get_annotators(db_dir, annotators):
342342

343343
if annotators is not None:
344344
# Check for an ANNOTATORS file
345-
r = requests.get(posixpath.join(db_url, 'ANNOTATORS'))
346-
if r.status_code == 404:
345+
try:
346+
content = _get_url(posixpath.join(db_url, 'ANNOTATORS'))
347+
except FileNotFoundError:
347348
if annotators == 'all':
348349
return
349350
else:
350351
raise ValueError('The database %s has no annotation files to download' % db_url)
352+
351353
# Make sure the input annotators are present in the database
352-
ann_list = r.content.decode('ascii').splitlines()
354+
ann_list = content.decode('ascii').splitlines()
353355
ann_list = [a.split('\t')[0] for a in ann_list]
354356

355357
# Get the annotation file types required

0 commit comments

Comments
 (0)