Skip to content

Commit 3cec71f

Browse files
author
Benjamin Moody
committed
get_record_list: 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 7f090fe commit 3cec71f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

wfdb/io/download.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,13 @@ def get_record_list(db_dir, records='all'):
300300

301301
# Check for a RECORDS file
302302
if records == 'all':
303-
response = requests.get(posixpath.join(db_url, 'RECORDS'))
304-
if response.status_code == 404:
303+
try:
304+
content = _get_url(posixpath.join(db_url, 'RECORDS'))
305+
except FileNotFoundError:
305306
raise ValueError('The database %s has no WFDB files to download' % db_url)
306307

307308
# Get each line as a string
308-
record_list = response.content.decode('ascii').splitlines()
309+
record_list = content.decode('ascii').splitlines()
309310
# Otherwise the records are input manually
310311
else:
311312
record_list = records

0 commit comments

Comments
 (0)