aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-12-11 10:58:45 -0500
committerBryan Quigley <code@bryanquigley.com>2020-12-13 15:05:47 -0800
commit46d0e38fda9f75d60882557371dd06760792faa6 (patch)
treefa3fd312316a807f0af83f545ef7f06fcf069b62
parentd7481c1bd7a81784143642cf47e0bb9b276daaae (diff)
downloadsos-46d0e38fda9f75d60882557371dd06760792faa6.tar.gz
[collect] Add unavailable warning to `sos collect --help`
Adds a warning message to the end of `sos collect --help` output when the `collect` component is not available due to a missing dependency or missing sub package. Closes: #2336 Resolves: #2341 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryan Quigley <code@bryanquigley.com>
-rw-r--r--sos/missing.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/sos/missing.py b/sos/missing.py
index e5897eaa..30c5b89c 100644
--- a/sos/missing.py
+++ b/sos/missing.py
@@ -14,6 +14,10 @@ class MissingCollect(SoSComponent):
load_policy = False
configure_logging = False
desc = '(unavailable) Collect an sos report from multiple nodes'
+ missing_msg = (
+ 'It appears likely that your distribution separately ships a package '
+ 'called sos-collector. Please install it to enable this function'
+ )
def execute(self):
sys.stderr.write(
@@ -30,15 +34,34 @@ class MissingCollect(SoSComponent):
"""
return []
+ @classmethod
+ def add_parser_options(cls, parser):
+ """Set the --help output for collect to a message that shows that
+ the functionality is unavailable
+ """
+ msg = "%s %s" % (
+ 'WARNING: `collect` is not available with this installation!',
+ cls.missing_msg
+ )
+ parser.epilog = msg
+ return parser
+
class MissingPexpect(MissingCollect):
"""This is used as a placeholder for when the collect component is locally
installed, but cannot be used due to a missing pexpect dependency.
"""
+ missing_msg = (
+ 'Please install the python3-pexpect package for your distribution in '
+ 'order to enable this function'
+ )
+
def execute(self):
sys.stderr.write(
"The collect command is unavailable due to a missing dependency "
"on python3-pexpect.\n\nPlease install python3-pexpect to enable "
"this functionality.\n"
)
+
+# vim: set et ts=4 sw=4 :