aboutsummaryrefslogtreecommitdiffstats
path: root/vnfsdk_pkgtools/packager/manifest.py
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2018-03-26 13:35:22 +0800
committerLianhao Lu <lianhao.lu@intel.com>2018-03-26 13:37:37 +0800
commitcd02d1f9b64957a63ad4b16bac639116975edb22 (patch)
tree1615d4af58dbe0354649e146e6dd3431977899d0 /vnfsdk_pkgtools/packager/manifest.py
parent432bca4baa6d704301b0c6e24026018212ecc368 (diff)
Added file digest computation
Support to compute file digest and save it to manifest file. Also extend the manifest file module to be able to write content into temporary file. Change-Id: If1f3f42799eb527bdeac418d1a40aa203641f628 Issue-ID: VNFSDK-174 Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 'vnfsdk_pkgtools/packager/manifest.py')
-rw-r--r--vnfsdk_pkgtools/packager/manifest.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/vnfsdk_pkgtools/packager/manifest.py b/vnfsdk_pkgtools/packager/manifest.py
index a2d9d70..d819a70 100644
--- a/vnfsdk_pkgtools/packager/manifest.py
+++ b/vnfsdk_pkgtools/packager/manifest.py
@@ -15,6 +15,7 @@
from collections import namedtuple
import os
+import tempfile
import udatetime
@@ -158,7 +159,13 @@ class Manifest(object):
ret += "Hash: %s\n" % digest[1]
return ret
- def update_to_file(self):
+ def update_to_file(self, temporary=False):
content = self.return_as_string()
- with open(os.path.join(self.root, self.path), 'w') as fp:
+ if temporary:
+ abs_path = tempfile.mktemp()
+ else:
+ abs_path = os.path.abspath(os.path.join(self.root, self.path))
+
+ with open(abs_path, 'w') as fp:
fp.write(content)
+ return abs_path