aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2016-02-12 13:24:08 +0000
committerBryn M. Reeves <bmr@redhat.com>2016-02-12 13:24:08 +0000
commit184de3818abbf602d198a5030bdada7989c44b46 (patch)
treeb290d35d1dd40b6417b4ca6f5f6bb2eb62968550
parentaa7fd5739f528cd9534fb4d86daff0e7c0e9bd06 (diff)
downloadsos-184de3818abbf602d198a5030bdada7989c44b46.tar.gz
[sosreport] fix '0 plugins' output in profile listings
When sosreport prints a profile listing as a result of the user selecting a non-existent profile we currently output a profile list (no plugin names) that ends with the standard summary of profiles and plugins: # sosreport -vv --batch --profile qux set sysroot to '/' (default) sosreport (version 3.2) Unknown or inactive profile(s) provided: qux The following profiles are available: boot cluster [...] system virt webserver 28 profiles, 0 plugins This is less than useful and confusing for users (who shouldn't have to care about how we manage this stuff internally). Change this to only include the ", N plugins" part of the text if we have actually loaded some valid plugins for the active profile and factor out common display code in list_plugins and list_profiles. Fixes: #733. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 03bd9984..85093831 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -945,11 +945,13 @@ class SoSReport(object):
using_profiles = len(self.opts.profiles)
policy_classes = self.policy.valid_subclasses
extra_classes = []
+
if self.opts.experimental:
extra_classes.append(sos.plugins.ExperimentalPlugin)
valid_plugin_classes = tuple(policy_classes + extra_classes)
validate_plugin = self.policy.validate_plugin
remaining_profiles = list(self.opts.profiles)
+
# validate and load plugins
for plug in plugins:
plugbase, ext = os.path.splitext(plug)
@@ -1094,6 +1096,14 @@ class SoSReport(object):
self.all_options.append((plugin, plugin_name, optname,
optparm))
+ def _report_profiles_and_plugins(self):
+ if len(self.loaded_plugins):
+ self.ui_log.info(" %d profiles, %d plugins"
+ % (len(self.profiles), len(self.loaded_plugins)))
+ else:
+ # no valid plugins for this profile
+ self.ui_log.info(" %d profiles" % len(self.profiles))
+
def list_plugins(self):
if not self.loaded_plugins and not self.skipped_plugins:
self.soslog.fatal(_("no valid plugins found"))
@@ -1145,8 +1155,7 @@ class SoSReport(object):
for line in lines:
self.ui_log.info(" %s" % line)
self.ui_log.info("")
- self.ui_log.info(" %d profiles, %d plugins"
- % (len(self.profiles), len(self.loaded_plugins)))
+ self._report_profiles_and_plugins()
self.ui_log.info("")
def list_profiles(self):
@@ -1170,8 +1179,7 @@ class SoSReport(object):
for line in lines:
self.ui_log.info(" %s" % line)
self.ui_log.info("")
- self.ui_log.info(" %d profiles, %d plugins"
- % (len(profiles), len(self.loaded_plugins)))
+ self._report_profiles_and_plugins()
self.ui_log.info("")
def batch(self):