From 94350cc0de2c63632f0e7aa04730b991d21bde7f Mon Sep 17 00:00:00 2001 From: "Bryn M. Reeves" Date: Mon, 1 Feb 2016 16:43:59 +0000 Subject: [archive] remove hand-rolled compression shell out The archive classes are not special snowflakes: they do not need their own (buggy) version of sos_get_command_output(): replace the hand-rolled Popen() call with the sos.utilities version. Really Fixes: #742. Signed-off-by: Bryn M. Reeves --- sos/archive.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sos/archive.py b/sos/archive.py index 0b968517..b129adf3 100644 --- a/sos/archive.py +++ b/sos/archive.py @@ -28,6 +28,8 @@ import sys # required for compression callout (FIXME: move to policy?) from subprocess import Popen, PIPE +from sos.utilities import sos_get_command_output + try: import selinux except ImportError: @@ -391,7 +393,7 @@ class TarFileArchive(FileCacheArchive): if self.method in methods: methods = [self.method] - last_error = Exception("compression failed for an unknown reason") + last_error = Exception("compression failed") for cmd in methods: suffix = "." + cmd.replace('ip', '') @@ -399,19 +401,14 @@ class TarFileArchive(FileCacheArchive): if cmd != "gzip": cmd = "%s -1" % cmd try: - command = shlex.split("%s %s" % (cmd, self.name())) - p = Popen(command, - stdout=PIPE, - stderr=PIPE, - bufsize=-1, - close_fds=True) - stdout, stderr = p.communicate() - if stdout: - self.log_info(stdout.decode('utf-8', 'ignore')) - if stderr: - self.log_error(stderr.decode('utf-8', 'ignore')) + r = sos_get_command_output("%s %s" % (cmd, self.name())) + + if r['status']: + self.log_info(r['output']) + self._suffix += suffix return self.name() + except Exception as e: last_error = e raise last_error -- cgit