Skip to content
Open
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
23 changes: 19 additions & 4 deletions utilities/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,25 @@ def download_and_extract_file_from_cluster(tmpdir, url):
LOGGER.info(f"Downloading archive using: url={url}")
urllib3.disable_warnings() # TODO: remove this when we fix the SSL warning
local_file_name = os.path.join(tmpdir, url.split("/")[-1])
with requests.get(url, verify=False, stream=True) as created_request:
created_request.raise_for_status()
with open(local_file_name, "wb") as file_downloaded:
file_downloaded.writelines(created_request.iter_content(chunk_size=8192))
for sample in TimeoutSampler(
wait_timeout=TIMEOUT_2MIN,
sleep=TIMEOUT_10SEC,
func=requests.get,
exceptions_dict={
requests.exceptions.SSLError: [],
requests.exceptions.ConnectionError: [],
requests.exceptions.Timeout: [],
},
url=url,
verify=False,
stream=True,
timeout=TIMEOUT_30SEC,
):
with sample:
sample.raise_for_status()
with open(local_file_name, "wb") as file_downloaded:
file_downloaded.writelines(sample.iter_content(chunk_size=8192))
break
LOGGER.info("Extract the downloaded archive.")
if url.endswith(zip_file_extension):
archive_file_object = zipfile.ZipFile(file=local_file_name)
Expand Down