diff options
author | Bozawglanian, Hagop (hb755d) <hb755d@att.com> | 2018-09-17 17:45:40 +0000 |
---|---|---|
committer | Bozawglanian, Hagop (hb755d) <hb755d@att.com> | 2018-09-17 20:20:05 +0000 |
commit | 5fe6216becd1d0451d356569de24fd68d49d9982 (patch) | |
tree | d8a91a8e7e70e35d1bcf4d47c35f62488e25fa6c /ice_validator/tests/conftest.py | |
parent | 60d5ad7d00eadd6395eca186e6fa76a43df3c6cf (diff) |
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) <hb755d@att.com>
Diffstat (limited to 'ice_validator/tests/conftest.py')
-rw-r--r-- | ice_validator/tests/conftest.py | 17 |
1 files changed, 13 insertions, 4 deletions
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: |