From 961f572383ff3398bcafc802682b92f23f8ab1fe Mon Sep 17 00:00:00 2001 From: "Lovett, Trevor" Date: Tue, 29 Jan 2019 14:14:44 -0600 Subject: [PATCH] [VVP] Removing dynamic download of needs.json Also resolving some flake8 failures Change-Id: I2de20975106de0308bc20c2a8944e3552f6f7cca Issue-ID: VVP-140 Signed-off-by: Lovett, Trevor --- ice_validator/tests/conftest.py | 24 +----------------------- ice_validator/vvp.py | 4 ++-- tox.ini | 12 ++++-------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index 5621354..1a47e63 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -47,9 +47,7 @@ import time from collections import defaultdict from itertools import chain -import requests import traceback -import warnings import docutils.core import jinja2 @@ -65,10 +63,7 @@ __path__ = [os.path.dirname(os.path.abspath(__file__))] DEFAULT_OUTPUT_DIR = "{}/../output".format(__path__[0]) RESOLUTION_STEPS_FILE = "resolution_steps.json" -HEAT_REQUIREMENTS_FILE = "heat_requirements.json" - -# noinspection PyPep8 -NEEDS_JSON_URL = "https://onap.readthedocs.io/en/latest/_downloads/789ac64d223325488fb3f120f959d985/needs.json" +HEAT_REQUIREMENTS_FILE = os.path.join(__path__[0], "..", "heat_requirements.json") REPORT_COLUMNS = [ ("Input File", "file"), @@ -1012,23 +1007,6 @@ def hash_directory(path): def load_current_requirements(): """Loads dict of current requirements or empty dict if file doesn't exist""" - try: - r = requests.get(NEEDS_JSON_URL) - if r.headers.get("content-type") == "application/json": - with open(HEAT_REQUIREMENTS_FILE, "wb") as needs: - needs.write(r.content) - else: - warnings.warn( - ( - "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)) - if not os.path.exists(HEAT_REQUIREMENTS_FILE): - return {} with io.open(HEAT_REQUIREMENTS_FILE, encoding="utf8", mode="r") as f: data = json.load(f) version = data["current_version"] diff --git a/ice_validator/vvp.py b/ice_validator/vvp.py index 9c63168..8d1fc69 100644 --- a/ice_validator/vvp.py +++ b/ice_validator/vvp.py @@ -185,7 +185,7 @@ class QueueWriter: def get_plugins() -> Optional[List]: - """When running in a frozen bundle, plugins need to be registered + """When running in a frozen bundle, plugins to be registered explicitly. This method will return the required plugins to register based on the run mode""" if hasattr(sys, "frozen"): @@ -682,7 +682,7 @@ class ValidatorApp: try: os.remove(self.report_file_path) return True - except OSError as e: + except OSError: messagebox.showerror( "Error", "Please close or rename the open report file before re-validating", diff --git a/tox.ini b/tox.ini index 34ba2cd..305378c 100644 --- a/tox.ini +++ b/tox.ini @@ -40,26 +40,22 @@ [tox] skipsdist=True -envlist = py36,style +envlist = py36 [testenv] distribute = False -basepython = python3.6 commands = {envpython} --version pytest --version coverage run --module pytest ice_validator/tests --self-test -rxXs coverage xml + flake8 --version + flake8 ice_validator deps = --no-use-pep517 -rrequirements.txt - flake8==3.4.1 + flake8==3.6.0 coverage==4.5.1 -[testenv:style] -commands = flake8 ice_validator - -[testenv:py36] -basepython=python3.6 [flake8] ignore = W391, W503, E501 -- 2.16.6