PAL: repeat the download if it fails 2 47/31547/1
authorTibor Frank <tifrank@cisco.com>
Fri, 5 Mar 2021 13:10:08 +0000 (14:10 +0100)
committerTibor Frank <tifrank@cisco.com>
Fri, 5 Mar 2021 13:10:08 +0000 (14:10 +0100)
Change-Id: I9bba50281bfe65f62a1cfab76364d834dc10d80c
Signed-off-by: Tibor Frank <tifrank@cisco.com>
resources/tools/presentation/input_data_files.py
resources/tools/presentation/requirements.txt

index 023d52a..e5b26e9 100644 (file)
@@ -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:
 
index 0063926..8e3d170 100644 (file)
@@ -8,3 +8,4 @@ pandas==0.25.3
 plotly==4.1.1
 PTable==0.9.2
 hdrhistogram==0.6.1
+urllib3==1.25.6