diff options
author | hewei-cmss <hewei@cmss.chinamobile.com> | 2019-05-07 20:53:57 +0800 |
---|---|---|
committer | hewei-cmss <hewei@cmss.chinamobile.com> | 2019-05-07 20:53:57 +0800 |
commit | dab16781d36319a849e3cac6fa003aa61682b6b9 (patch) | |
tree | 222f010d8af38d87307a7079d930555df3e598d0 | |
parent | 68722c34f7deee9457e21b5db2bb5c3b6d3a05ff (diff) |
modify fetch vnf pkg aritfacts
Close file and add exception
Issue-ID: VFC-1377
Change-Id: I0f60bb6a268069fd5db4367cd0b45bc7b116eeb2
Signed-off-by: hewei-cmss <hewei@cmss.chinamobile.com>
-rw-r--r-- | catalog/packages/biz/vnf_pkg_artifacts.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/catalog/packages/biz/vnf_pkg_artifacts.py b/catalog/packages/biz/vnf_pkg_artifacts.py index d8a77488..bb79624b 100644 --- a/catalog/packages/biz/vnf_pkg_artifacts.py +++ b/catalog/packages/biz/vnf_pkg_artifacts.py @@ -36,5 +36,8 @@ class FetchVnfPkgArtifact(object): artifact_path = fileutil.get_artifact_path(vnf_extract_path, artifactPath) if not artifact_path: raise ArtifactNotFoundException("Couldn't artifact %s" % artifactPath) - file_content = open(artifact_path, 'rb').read() + with open(artifact_path, 'rb') as f: + file_content = f.read() + else: + raise ArtifactNotFoundException("NF Package format is not csar or zip") return file_content |