From 0ef9c196b42b8c9182710b0f937f775199b0feea Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Tue, 17 Mar 2020 14:28:38 +0100 Subject: Post-processed data from DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It removes base_url to match the location in archive. It forces a relative path by removing first "/". It makes sense but it may raise side effects in dovetail webportal. Change-Id: Idca69a99fed54ddf69334a865bae15b0a08220fc Signed-off-by: Cédric Ollivier --- xtesting/core/campaign.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xtesting/core/campaign.py b/xtesting/core/campaign.py index 60af3f46..7c766e53 100644 --- a/xtesting/core/campaign.py +++ b/xtesting/core/campaign.py @@ -71,9 +71,17 @@ class Campaign(): "{}?build_tag={}".format(url, env.get('BUILD_TAG')), headers=testcase.TestCase.headers) req.raise_for_status() - Campaign.__logger.debug("data from DB: \n%s", req.json()) + output = req.json() + Campaign.__logger.debug("data from DB: \n%s", output) + for i, _ in enumerate(output["results"]): + for j, _ in enumerate( + output["results"][i]["details"]["links"]): + output["results"][i]["details"]["links"][j] = re.sub( + "^{}/*".format(os.environ["HTTP_DST_URL"]), '', + output["results"][i]["details"]["links"][j]) + Campaign.__logger.debug("data to archive: \n%s", output) with open("{}.json".format(env.get('BUILD_TAG')), "w") as dfile: - json.dump(req.json(), dfile) + json.dump(output, dfile) except Exception: # pylint: disable=broad-except Campaign.__logger.exception( "The results cannot be collected from DB") -- cgit 1.2.3-korg