aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-07-10 15:49:30 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-07-10 19:22:04 +0100
commit69cd97fd4f3be984be25cbd65b9b3255dfe3d356 (patch)
treec3093ef29104bceeb81a5af6830280a8a79a01c5
parent4f1bbb5444946138d76bf3ca28cc53893213abc4 (diff)
downloadsos-69cd97fd4f3be984be25cbd65b9b3255dfe3d356.tar.gz
[sosreport,archive] fix command line compression method selection
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/archive.py7
-rw-r--r--sos/sosreport.py12
2 files changed, 14 insertions, 5 deletions
diff --git a/sos/archive.py b/sos/archive.py
index a6394cfc..4838ddd9 100644
--- a/sos/archive.py
+++ b/sos/archive.py
@@ -113,7 +113,7 @@ class Archive(object):
"""Finalize an archive object via method. This may involve creating
An archive that is subsequently compressed or simply closing an
archive that supports in-line handling. If method is automatic then
- the following technologies are tried in order: xz, bz2 and gzip"""
+ the following methods are tried in order: xz, bz2 and gzip"""
self.close()
@@ -222,11 +222,13 @@ class FileCacheArchive(Archive):
shutil.rmtree(self._archive_root)
def finalize(self, method):
- self.log_info("finalizing archive '%s'" % self._archive_root)
+ self.log_info("finalizing archive '%s' using method '%s'"
+ % (self._archive_root, method))
self._build_archive()
self.cleanup()
self.log_info("built archive at '%s' (size=%d)" % (self._archive_name,
os.stat(self._archive_name).st_size))
+ self.method = method
return self._compress()
@@ -301,6 +303,7 @@ class TarFileArchive(FileCacheArchive):
cmd = "%s -1" % cmd
try:
command = shlex.split("%s %s" % (cmd, self.name()))
+ print "%s %s" % (cmd, self.name())
p = Popen(command,
stdout=PIPE,
stderr=PIPE,
diff --git a/sos/sosreport.py b/sos/sosreport.py
index fc7dc527..90890643 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -608,9 +608,6 @@ class SoSReport(object):
return self.tempfile_util.new()
def _set_archive(self):
- if self.opts.compression_type not in ('auto', 'zip', 'bzip2', 'gzip', 'xz'):
- raise Exception("Invalid compression type specified. Options are:" +
- "auto, zip, bzip2, gzip and xz")
archive_name = os.path.join(self.tmpdir,self.policy.get_archive_name())
if self.opts.compression_type == 'auto':
auto_archive = self.policy.get_preferred_archive()
@@ -956,6 +953,15 @@ class SoSReport(object):
self.policy.pre_work()
try:
self.ui_log.info(_(" Setting up archive ..."))
+ compression_methods = ('auto', 'zip', 'bzip2', 'gzip', 'xz')
+ method = self.opts.compression_type
+ if method not in compression_methods:
+ compression_list = ', '.join (compression_methods)
+ self.ui_log.error("")
+ self.ui_log.error("Invalid compression specified: " + method)
+ self.ui_log.error("Valid types are: " + compression_list)
+ self.ui_log.error("")
+ self._exit(1)
self._set_archive()
self._make_archive_paths()
return