change if bad to assert not bad, message
[vvp/validation-scripts.git] / update_reqs.py
1 # ============LICENSE_START====================================================
2 # org.onap.vvp/validation-scripts
3 # ===================================================================
4 # Copyright © 2019 AT&T Intellectual Property. All rights reserved.
5 # ===================================================================
6 #
7 # Unless otherwise specified, all software contained herein is licensed
8 # under the Apache License, Version 2.0 (the "License");
9 # you may not use this software except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #             http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20 #
21 #
22 # Unless otherwise specified, all documentation contained herein is licensed
23 # under the Creative Commons License, Attribution 4.0 Intl. (the "License");
24 # you may not use this documentation except in compliance with the License.
25 # You may obtain a copy of the License at
26 #
27 #             https://creativecommons.org/licenses/by/4.0/
28 #
29 # Unless required by applicable law or agreed to in writing, documentation
30 # distributed under the License is distributed on an "AS IS" BASIS,
31 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 # See the License for the specific language governing permissions and
33 # limitations under the License.
34 #
35 # ============LICENSE_END============================================
36 #
37
38 """
39 This script will refresh the heat_requirements.json file by pulling the
40 latest version from Nexus.
41 """
42 import os
43 from urllib import request
44
45 from ice_validator import version
46
47 REQS_URL = (
48     f"https://nexus.onap.org/"
49     f"content/sites/raw/org.onap.vnfrqts.requirements/{version.BRANCH}/needs.json"
50 )
51
52 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
53
54
55 def get_requirements():
56     """Retrieves the binary JSON content fom REQS_URL"""
57     return request.urlopen(REQS_URL)  # nosec
58
59
60 def write_file(contents, path):
61     with open(path, "wb") as f:
62         f.write(contents)
63
64
65 if __name__ == "__main__":
66     reqs = get_requirements().read()
67     write_file(reqs, os.path.join(THIS_DIR, "ice_validator/heat_requirements.json"))