Devserver: logging all errors in extracting tarball.
This CL separates the stdout and stderr of command 'tar', and log the error
message if stderr is not empty.
BUG=chromium:659850
TEST=Create a future file, tar -czvf it, and then call
common_util.ExtractTarball to verify.
Change-Id: I45d333847843f37048927a2cca273327f28adad8
Reviewed-on: https://chromium-review.googlesource.com/412305
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/common_util.py b/common_util.py
index 0ee591b..b0092d8 100644
--- a/common_util.py
+++ b/common_util.py
@@ -371,7 +371,7 @@
# Deal with exclusions.
# Add 'm' for not extracting file's modified time. All extracted files are
# marked with current system time.
- cmd = ['tar', 'xfm', tarball_path, '--directory', install_path]
+ cmd = ['tar', 'xf', tarball_path, '--directory', install_path]
# If caller requires the list of extracted files, get verbose.
if return_extracted_files:
@@ -393,9 +393,13 @@
cmd_output = ''
try:
- # TODO(xixuan): not merge error msg to stdout to avoid missing error msg.
- # crbug.com/662793
- cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ cmd_output, cmd_error = proc.communicate()
+ if cmd_error:
+ _Log('Error happened while in extracting tarball: %s',
+ cmd_error.rstrip())
+
if return_extracted_files:
return [os.path.join(install_path, filename)
for filename in cmd_output.strip('\n').splitlines()