aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/input_data_files.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2021-03-05 14:10:08 +0100
committerTibor Frank <tifrank@cisco.com>2021-03-05 14:10:08 +0100
commitb83a029d3c6524b7f0139746fcc4325e692976b6 (patch)
tree6409fbd22b50e5df77a4db070519278e6f30a27b /resources/tools/presentation/input_data_files.py
parent4d5e0d3bc3e5e58ebc91d52766ab9d146c52ba58 (diff)
PAL: repeat the download if it fails 2
Change-Id: I9bba50281bfe65f62a1cfab76364d834dc10d80c Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/input_data_files.py')
-rw-r--r--resources/tools/presentation/input_data_files.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/resources/tools/presentation/input_data_files.py b/resources/tools/presentation/input_data_files.py
index 023d52a0d6..e5b26e910c 100644
--- a/resources/tools/presentation/input_data_files.py
+++ b/resources/tools/presentation/input_data_files.py
@@ -21,7 +21,7 @@ import gzip
from os import rename, mkdir
from os.path import join
-from http.client import responses, IncompleteRead
+from http.client import responses, HTTPException
from zipfile import ZipFile, is_zipfile, BadZipfile
import requests
@@ -30,6 +30,8 @@ from requests.adapters import HTTPAdapter, Retry
from requests.exceptions import RequestException
from requests import codes
+from urllib3.exceptions import HTTPError
+
from pal_errors import PresentationError
@@ -89,9 +91,9 @@ def _download_file(url, file_name, arch=False, verify=True, repeat=1):
session.mount(u"https://", adapter)
return session
+ success = False
while repeat:
repeat -= 1
- success = False
session = None
try:
logging.info(f" Connecting to {url} ...")
@@ -137,7 +139,7 @@ def _download_file(url, file_name, arch=False, verify=True, repeat=1):
success = True
repeat = 0
- except IncompleteRead as err:
+ except (HTTPException, HTTPError) as err:
logging.error(f"Connection broken:\n{repr(err)}")
except RequestException as err:
logging.error(f"HTTP Request exception:\n{repr(err)}")
@@ -247,7 +249,9 @@ def download_and_unzip_data_file(spec, job, build, pid):
logging.info(f"Trying to download {url}")
arch = bool(spec.configuration.get(u"archive-inputs", True))
- success, downloaded_name = _download_file(url, new_name, arch=arch)
+ success, downloaded_name = _download_file(
+ url, new_name, arch=arch, verify=True, repeat=3
+ )
if not success: