File: missing.py

package info (click to toggle)
sosreport 4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,800 kB
  • sloc: python: 20,375; sh: 166; makefile: 3
file content (44 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

import sys
from sos.component import SoSComponent


class MissingCollect(SoSComponent):
    """This is used as a placeholder for when the local sos installation
    attempts to import sos.collector, but that module is not present. In those
    scenarios, it means that sos has been split into sub-packages. Barring
    incorrect splitting, this 'sos.missing' module should always be available
    to the main sos package.
    """

    load_policy = False
    configure_logging = False
    desc = '(unavailable) Collect an sos report from multiple nodes'

    def execute(self):
        sys.stderr.write(
            "The collect command is unavailable as it appears to be packaged "
            "separately for your distribution.\n\nPlease install the latest "
            "sos-collector package to enable this functionality.\n"
        )

    def load_options(self):
        """Override the normal component method to basically ignore all options
        given, so that we always print the error message that collect is
        unavailable, rather than failing on the parser when collect is called
        with options.
        """
        return []


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.
    """

    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"
        )