aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/input_data_files.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2018-02-12 13:36:34 +0100
committerTibor Frank <tifrank@cisco.com>2018-02-13 09:48:18 +0100
commit6addc914c636a0dbc1e12a661019cce1715baf77 (patch)
tree9c36bf7606e4b15d7e2c0f876ff0d604f1d01baa /resources/tools/presentation/input_data_files.py
parentfd987b10941ca09a54cf0325c2b097b734bdbc94 (diff)
CSIT-891: Add data sources for 1801 report
Change-Id: I320737f2edbf74caa8f12177dcc7186a88920a9a 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.py37
1 files changed, 31 insertions, 6 deletions
diff --git a/resources/tools/presentation/input_data_files.py b/resources/tools/presentation/input_data_files.py
index d57d1545ea..7dae834b4d 100644
--- a/resources/tools/presentation/input_data_files.py
+++ b/resources/tools/presentation/input_data_files.py
@@ -15,6 +15,8 @@
Download all data.
"""
+import re
+
import logging
from os import rename, remove
@@ -34,6 +36,8 @@ CHUNK_SIZE = 512
# Separator used in file names
SEPARATOR = "__"
+REGEX_RELEASE = re.compile(r'(\D*)(\d{4})(\D*)')
+
def download_data_files(spec):
"""Download all data specified in the specification file in the section
@@ -59,21 +63,42 @@ def download_data_files(spec):
url = "{0}/{1}".format(url, full_name)
new_name = join(
spec.environment["paths"]["DIR[WORKING,DATA]"],
- "{job}{sep}{build}{sep}{name}".format(job=job, sep=SEPARATOR,
+ "{job}{sep}{build}{sep}{name}".format(job=job,
+ sep=SEPARATOR,
build=build["build"],
name=file_name))
-
- logging.info("Downloading the file '{0}' to '{1}'.".
- format(url, new_name))
+ logging.info(
+ "Downloading the file '{0}' to '{1}' ...".format(url, new_name))
status = "failed"
try:
response = get(url, stream=True)
code = response.status_code
if code != codes["OK"]:
- logging.error("{0}: {1}".format(code, responses[code]))
+ logging.warning(
+ "Jenkins: {0}: {1}.".format(code, responses[code]))
+ logging.info("Trying to download from Nexus:")
spec.set_input_state(job, build["build"], "not found")
- continue
+ if code == codes["not_found"]:
+ release = re.search(REGEX_RELEASE, job).group(2)
+ nexus_file_name = "{job}{sep}{build}{sep}{name}".\
+ format(job=job, sep=SEPARATOR, build=build["build"],
+ name=file_name)
+ url = "{url}/rls{release}/{dir}/{file}".\
+ format(url=spec.environment["urls"]["URL[NEXUS]"],
+ release=release,
+ dir=spec.environment["urls"]["DIR[NEXUS]"],
+ file=nexus_file_name)
+ logging.info("Downloading the file '{0}' to '{1}' ...".
+ format(url, new_name))
+ response = get(url, stream=True)
+ code = response.status_code
+ if code != codes["OK"]:
+ logging.error(
+ "Nexus: {0}: {1}".format(code, responses[code]))
+ spec.set_input_state(
+ job, build["build"], "not found")
+ continue
file_handle = open(new_name, "wb")
for chunk in response.iter_content(chunk_size=CHUNK_SIZE):