Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion astrodata/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import numpy as np
import requests
import requests.adapters
import urllib3.util # For http retries in requests
from astropy.io import fits
from astropy.table import Table
from astropy.utils.data import download_file
Expand Down Expand Up @@ -655,6 +657,13 @@ def download_from_archive(
if url is None:
url = GEMINI_ARCHIVE_URL + filename

# Set up a requests session and configure re-tries
reqses = requests.Session()
retries = urllib3.util.Retry(total=5, backoff_factor=1)
reqses.mount(
"https://", requests.adapters.HTTPAdapter(max_retries=retries)
)

# Now check if the local file exists and download if not
try:
download_it = True
Expand All @@ -670,7 +679,7 @@ def download_from_archive(
fileinfourl = url.replace(
"/file/", "/jsonfilelist/present/filename="
)
fileinfo = requests.get(
fileinfo = reqses.get(
fileinfourl, headers={"User-Agent": "astropy"}
).json()
goa_md5 = fileinfo[0].get("data_md5")
Expand Down
Loading