From b2acba1e55b9631b67aba80d40d23435aae3b891 Mon Sep 17 00:00:00 2001 From: Lihong Sun Date: Thu, 11 Dec 2014 01:56:25 -0500 Subject: [PATCH] Update tar command option List whole files to the tar command instead of giving a dir Change-Id: I1916924eaf63876c9d4fe0bcfa64f4f8e142a42e --- mic/archive.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mic/archive.py b/mic/archive.py index 35571ce..a612389 100644 --- a/mic/archive.py +++ b/mic/archive.py @@ -248,16 +248,18 @@ def _do_tar(archive_name, target_name): @target_name: the name of the target to tar @retval: the path of the archived file """ + file_list = [] if os.path.isdir(target_name): target_dir = target_name target_name = "." + for target_file in os.listdir(target_dir): + file_list.append(target_file) else: target_dir = os.path.dirname(target_name) target_name = os.path.basename(target_name) - - cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name, target_name] - - + file_list.append(target_name) + cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name] + cmdln.extend(file_list) _call_external(cmdln) return archive_name @@ -271,9 +273,7 @@ def _do_untar(archive_name, target_dir=None): """ if not target_dir: target_dir = os.getcwd() - cmdln = ["tar", "-S", "-C", target_dir, "-xf", archive_name] - (returncode, stdout, stderr) = _call_external(cmdln) if returncode != 0: raise OSError, os.linesep.join([stdout, stderr]) -- 2.7.4