use 'gzip' and 'bzip2' to pack image instead
authorGui Chen <gui.chen@intel.com>
Mon, 9 Jul 2012 03:28:06 +0000 (11:28 +0800)
committerGui Chen <gui.chen@intel.com>
Mon, 9 Jul 2012 03:28:06 +0000 (11:28 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/utils/misc.py

index 1360be1..44ced2b 100644 (file)
@@ -91,10 +91,9 @@ def taring(dstfile, target):
             ".bz2": "bz2", # for .tar.bz2
             ".tgz": "gz",
             ".tbz": "bz2"}[ext]
-    if not comp:
-        wf = tarfile.open(dstfile, 'w')
-    else:
-        wf = tarfile.open(dstfile, 'w:' + comp)
+
+    wf = tarfile.open(dstfile, 'w')
+
     if os.path.isdir(target):
         for item in os.listdir(target):
             wf.add(os.path.join(target, item), item)
@@ -102,6 +101,10 @@ def taring(dstfile, target):
         wf.add(target, os.path.basename(target))
     wf.close()
 
+    if comp:
+        compressing(dstfile, comp)
+        shutil.move("%s.%s" % (dstfile, comp), dstfile)
+
 def ziping(dstfile, target):
     import zipfile
     wf = zipfile.ZipFile(dstfile, 'w', compression=zipfile.ZIP_DEFLATED)