aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2018-06-08 11:20:04 -0400
committerBryn M. Reeves <bmr@redhat.com>2018-06-18 15:49:43 +0100
commita065c50b5cfb8827063c2dcb9357a7e8de6b8035 (patch)
tree6aaaa64fd29a3f5c55b1111de65d896dcd9e139f
parent294d829ba148781606065388d71905735cf8b82c (diff)
downloadsos-a065c50b5cfb8827063c2dcb9357a7e8de6b8035.tar.gz
[sosreport] Fix threads execution with no options and output formatting
Fixes an issue where sosreport would not run due to an unset number of threads if 'sosreport' was run bare, with no options. Any option (threads or otherwise) would mask this problem due to how the default threads value was set by the parser. Now sosreport can be run without any options and run normally, with the concurrency provided by the threads. Additionally, changes the status line printed during plugin execution to be of a fixed length, so that output lines are not mangled when the status line is updated, rather than a new line being printed (such as what happens when using --batch). Resolves: #1336 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 75e33e83..6c08d123 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -225,6 +225,7 @@ class SoSOptions(object):
_sysroot = None
_chroot = 'auto'
_compression_type = 'auto'
+ _threads = 4
_options = None
@@ -1311,10 +1312,12 @@ class SoSReport(object):
self.running_plugs.append(plugname)
except:
return False
- status_line = " Starting {:<5}: {:<15} [Running: {}]".format(
- '%d/%d' % (count, len(self.loaded_plugins)),
+ numplugs = len(self.loaded_plugins)
+ status_line = " Starting %-5s %-15s %s" % (
+ "%d/%d" % (count, numplugs),
plugname,
- ' '.join(p for p in self.running_plugs))
+ "[Running: %s]" % ' '.join(p for p in self.running_plugs)
+ )
self.ui_progress(status_line)
try:
plug.collect()
@@ -1332,11 +1335,12 @@ class SoSReport(object):
status = ''
if (len(self.pluglist) <= int(self.opts.threads) and
self.running_plugs):
- status = " Finishing plugins %-13s [Running: %s]" % (
- ' ',
- ' '.join(p for p in self.running_plugs))
- if not self.pluglist and not self.running_plugs:
- status = " Finished running plugins"
+ status = " Finishing plugins %-12s %s" % (
+ " ",
+ "[Running: %s]" % (' '.join(p for p in self.running_plugs))
+ )
+ if not self.running_plugs:
+ status = "\n Finished running plugins"
if status:
self.ui_progress(status)
except (OSError, IOError) as e:
@@ -1350,7 +1354,7 @@ class SoSReport(object):
def ui_progress(self, status_line):
if self.opts.verbosity == 0:
- status_line = "\r%s" % status_line
+ status_line = "\r%s" % status_line.ljust(90)
else:
status_line = "%s\n" % status_line
if not self.opts.quiet: