aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2016-02-01 16:43:59 +0000
committerBryn M. Reeves <bmr@redhat.com>2016-02-01 16:46:06 +0000
commit94350cc0de2c63632f0e7aa04730b991d21bde7f (patch)
tree3fb15257f00bfbb94c954be87f0a5aac6dae99ec
parent691e629359a23ca6cefbce8b3942c378a17c6b9c (diff)
downloadsos-94350cc0de2c63632f0e7aa04730b991d21bde7f.tar.gz
[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 <bmr@redhat.com>
-rw-r--r--sos/archive.py21
1 files 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