Skip to content

Commit 0760fac

Browse files
author
Benjamin Moody
committed
dl_database: use openurl in place of requests.
Note that this will avoid downloading the index since its contents are not used. Furthermore, when trying to enumerate annotation files, this will handle errors other than 404 errors, and raise an exception as appropriate.
1 parent 4ffdc51 commit 0760fac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

wfdb/io/record.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,8 +4528,7 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
45284528
db_dir = posixpath.join(db_dir, get_version(db_dir))
45294529
db_url = posixpath.join(download.PN_CONTENT_URL, db_dir) + '/'
45304530
# Check if the database is valid
4531-
r = requests.get(db_url)
4532-
r.raise_for_status()
4531+
_url.openurl(db_url, check_access=True)
45334532

45344533
# Get the list of records
45354534
record_list = download.get_record_list(db_dir, records)
@@ -4586,10 +4585,11 @@ def dl_database(db_dir, dl_dir, records='all', annotators='all',
45864585
for a in annotators:
45874586
ann_file = rec+'.'+a
45884587
url = posixpath.join(download.config.db_index_url, db_dir, ann_file)
4589-
rh = requests.head(url)
4590-
4591-
if rh.status_code != 404:
4588+
try:
4589+
_url.openurl(url, check_access=True)
45924590
all_files.append(ann_file)
4591+
except FileNotFoundError:
4592+
pass
45934593

45944594
dl_inputs = [(os.path.split(file)[1], os.path.split(file)[0], db_dir, dl_dir, keep_subdirs, overwrite) for file in all_files]
45954595

0 commit comments

Comments
 (0)