From 5fe6216becd1d0451d356569de24fd68d49d9982 Mon Sep 17 00:00:00 2001 From: "Bozawglanian, Hagop (hb755d)" Date: Mon, 17 Sep 2018 17:45:40 +0000 Subject: VVP - Fixing script for traceability csv Fixing try catch to account for service outage. Issue-ID: VNFRQTS-236 Change-Id: Ic7ef03215fa4ed6319d7b5e986828bc83c17465a Signed-off-by: Bozawglanian, Hagop (hb755d) --- ice_validator/tests/conftest.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'ice_validator/tests') diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index a08b99a..8650c69 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -46,6 +46,7 @@ import sys import time import requests import traceback +import warnings import docutils.core import jinja2 @@ -593,10 +594,18 @@ def load_current_requirements(): """Loads dict of current requirements or empty dict if file doesn't exist""" url = 'https://onap.readthedocs.io/en/latest/_downloads/needs.json' - r = requests.get(url) - with open('requirements.json', 'wb') as needs: - needs.write(r.content) - path = "heat_requirements.json" + + try: + r = requests.get(url) + if r.headers.get('content-type') == 'application/json': + with open('requirements.json', 'wb') as needs: + needs.write(r.content) + else: + warnings.warning("Unexpected content-type ({}) encountered downloading requirements.json, using last saved copy".format(r.headers.get('content-type'))) + except requests.exceptions.RequestException as e: + warnings.warn("Error downloading latest JSON, using last saved copy.") + warnings.warn(UserWarning(e)) + path = "requirements.json" if not os.path.exists(path): return {} with io.open(path, encoding="utf8", mode="r") as f: -- cgit 1.2.3-korg