From d26b1982333e28bd4def87ccc9fa877a642dc82a Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Tue, 26 May 2020 08:39:02 -0700 Subject: [TEST] updating ovp listener for sha generation cherry-pick from master Issue-ID: TEST-233 Signed-off-by: stark, steven Change-Id: If8af6eae4763e35cc7745bc6e70a12b287ef1917 --- robotframework-onap/listeners/OVPListener.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/robotframework-onap/listeners/OVPListener.py b/robotframework-onap/listeners/OVPListener.py index 508568b..69fd3ba 100644 --- a/robotframework-onap/listeners/OVPListener.py +++ b/robotframework-onap/listeners/OVPListener.py @@ -22,7 +22,7 @@ from zipfile import ZipFile OUTPUT_DATA = { "vnf_checksum": "", "build_tag": "", - "version": "2019.09", + "version": "2019.12", "test_date": "", "duration": "", "vnf_type": "heat", @@ -107,19 +107,18 @@ class OVPListener: def sha256(template_directory): heat_sha = None + zip_file = "{}/tmp.zip".format(template_directory) + onlyfiles = [f for f in os.listdir(template_directory) if os.path.isfile(os.path.join(template_directory, f))] - if os.path.exists(template_directory): - zip_file = "{}/tmp_heat.zip".format(template_directory) - with ZipFile(zip_file, "w") as zip_obj: - for folder_name, subfolders, filenames in os.walk(template_directory): - for filename in filenames: - file_path = os.path.join(folder_name, filename) - zip_obj.write(file_path) + with ZipFile(zip_file, 'w') as zipObj: + for filename in onlyfiles: + zipObj.write(os.path.join(template_directory, filename), arcname=filename) - with open(zip_file, "rb") as f: - bytes = f.read() - heat_sha = hashlib.sha256(bytes).hexdigest() + with open(zip_file, "rb") as f: + bytes = f.read() + heat_sha = hashlib.sha256(bytes).hexdigest() + if os.path.exists(zip_file): os.remove(zip_file) return heat_sha -- cgit 1.2.3-korg