HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/sos/help/__pycache__/__init__.cpython-38.pyc
U

i��d�*�@s�ddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZzee��jd�ZWnek
r�dZYnXGd	d
�d
e�ZGdd�d�ZdS)
�N)�OrderedDict)�SoSComponent)�
import_policy)�Plugin)�bold�ImporterHelper)�fill�xcs�eZdZdZdZdZdZdZddiZ�fdd�Z	e
dd	��Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�ZS)�	SoSHelperz�Provide better, more in-depth help for specific parts of sos than is
    provided in either standard --help output or in manpages.
    zDetailed help infomationF�topic�cs"tt|��|||�|jj|_dS)N)�superr
�__init__�optsr)�self�parser�argsZcmdline��	__class__��3/usr/lib/python3/dist-packages/sos/help/__init__.pyr+szSoSHelper.__init__cCs*d|_|�dd�}|jdddddd	�dS)
Nzsos help TOPIC [options]zHelp Information Optionsz<These options control what detailed information is displayedrZTOPICr�?z/name of the topic or component to show help for)�metavar�default�nargs�help)�usageZadd_argument_group�add_argument)�clsrZhelp_grprrr�add_parser_options/s��zSoSHelper.add_parser_optionscCsB|jj�d�d}dddd�}||kr>|jj�|||�|j_dS)N�.r�cleaner�	collector)�clean�mask�collect)rr�split�replace)rZ_com�_replacerrr�sanitize_topic_component:s�z"SoSHelper.sanitize_topic_componentc
Cs�|jjs|��t�d�|��z|��}Wn@tk
rn}z"td|jj|f�t�d�W5d}~XYnX|r�zt	�}|�
|�|��Wq�tk
r�}ztd|�W5d}~XYq�Xntd|jj�dS)Nrz Could not load help for '%s': %s�zError loading help: %szNo help section found for '%s')rr�display_self_help�sys�exitr)�get_obj_for_topic�	Exception�print�HelpSectionZdisplay_help�display)r�klass�errZhtrrr�executeDs"

 zSoSHelper.executecCs�dddddddd�}d	}|jj|krJt�d
|jj�}t|||jj�}n<|j|j|j|jd�}|D] }|jj�	|�rd||�}q�qd|S)z�Based on the help topic we're after, try to smartly decide which
        object we need to manipulate in order to get help information.
        Z	SoSReportrZ
SoSCleaner�SoSCollectorZRemoteTransportZClusterZPolicy)�report�report.pluginsr!r"zcollector.transportszcollector.clusters�policiesN�sos.)zreport.plugins.z	policies.zcollector.transports.zcollector.clusters.)
rr�	importlib�
import_module�getattr�_get_plugin_variant�_get_policy_by_name�_get_collect_transport�_get_collect_cluster�
startswith)rZ
static_mapr�modZ_helpZ_secrrrr.\s,�
�
zSoSHelper.get_obj_for_topiccCs2ddlm}|jj�d�d}||kr.||SdS)Nr)�
TRANSPORTSr ���)Zsos.collector.sosnoderDrrr&)rrDZ
_transportrrrr@|sz SoSHelper._get_collect_transportcCsXddlm}ddl}|�|jjd�}|D]*}|d|jj�d�dkr(|dSq(dS)Nr)r6�clustersr rEr*)	Z
sos.collectorr6Zsos.collector.clustersZ
_load_modulesr"rFrrr&)rr6�sosrFZclusterrrrrA�s
�zSoSHelper._get_collect_clustercCsdt�d|jj�}|��t�|tj�}dd�|D�}|D]$}|��r:|j	�
|���}|Sq:dS)Nr:cSs"g|]}t|dt�r|d�qS)r*)�
issubclassr)�.0�mrrr�
<listcomp>�sz1SoSHelper._get_plugin_variant.<locals>.<listcomp>)r;r<rrZload_local_policy�inspectZ
getmembersZisclass�__subclasses__�policyZmatch_plugin)rrCZmemsZpluginsZpluginrrrrr>�szSoSHelper._get_plugin_variantcCsl|jj�d�d}ddl}t|jj�}|��D]8}t|�D]*}|j	�
��dd�}||kr:|Sq:q.dS)Nr rErrNr)rrr&Zsos.policies.distrosrr9ZdistrosZget_modulesr�__name__�lowerr')rZ_topicrGZ_helperrCrNZ_prrrr?�szSoSHelper._get_policy_by_namecCs�tdd�}|�dtd��|�d�}td�}|�d|�td�}|�d	|�|�d
�}|�d�dd
ddddd�}|D]"}|jd�t|�||�dd�q||��dS)zhDisplays the help information for this component directly, that is
        help for `sos help`.
        zDetailed help for sos helpz�The 'help' sub-command is used to provide more detailed information on different sub-commands available to sos as well as different components at play within those sub-commands.ahSoS - officially pronounced "ess-oh-ess" - is a diagnostic and supportability utility used by several Linux distributions as an easy-to-use tool for standardized data collection. The most known component of which is %s (formerly sosreport) which is used to collect troubleshooting information into an archive for review by sysadmins or technical support teams.z
sos reportzHow to search using sos helpz$component.$topic.$subtopicz<To get more information on a given topic, use the form '%s'.zsos help report.plugins.kernelz\For example '%s' will provide more information on the kernel plugin for the report function.zAvailable Help Sectionsz�The following help sections are available. Additional help topics and subtopics may be displayed within their respective help section.
z#Detailed help on the report commandz'Information on the plugin design of sosz!Information on a specific $pluginz"Detailed help on the clean commandz$Detailed help on the collect commandz+How sos operates on different distributions)r7r8zreport.plugins.$pluginr#r%r9z		{:<36}{}F)�newlineN)r1�add_textr�add_section�formatr2)rZ	self_helpZsubsectrZrep_exZ
avail_help�sectionsZsectrrrr+�sJ���

���
��	�zSoSHelper.display_self_help)rO�
__module__�__qualname__�__doc__ZdescZconfigure_loggingZload_policyZ
load_probeZarg_defaultsr�classmethodrr)r5r.r@rAr>r?r+�
__classcell__rrrrr
s&�


 	
r
c@sHeZdZdZddd�Zdd�Zddd	�Zdd
d�Zddd
�Zdd�Z	dS)r1z�This class is used to build the output displayed by `sos help` in a
    standard fashion that provides easy formatting controls.
    rcCs||_||_||_t�|_dS)a�
        :param title:   The title of the output section, will be prominently
                        displayed
        :type title:    ``str``

        :param content: The text content to be displayed with this section
        :type content:  ``str``

        :param indent:  If the section should be nested, set this to a multiple
                        of 4.
        :type indent:   ``int``
        N)�title�content�indentrrU�rr[r\r]rrrr�s
zHelpSection.__init__cCs
||_dS)z�Set or override the title for this help section

        :param title:   The name to set for this help section
        :type title:    ``str``
        N)r[)rr[rrr�	set_title�szHelpSection.set_titleTcCs,|jr|rdnd}||}|j|7_dS)z�Add body text to this section. If content for this section already
        exists, append the new ``content`` after a newline.

        :param content:     The text to add to the section
        :type content:      ``str``
        z

�
N)r\)rr\rQ�lnrrrrR�szHelpSection.add_textcCs|�|||�|j|S)acAdd a section of text to the help section that will be displayed
        when the HelpSection object is printed.

        Sections will be printed *in the order added*.

        This will return a subsection object with which block(s) of text may be
        added to the subsection associated with ``title``.

        :param title:   The title of the subsection being added
        :type title:    ``str``

        :param content: The text the new section should contain
        :type content:  ``str``

        :returns:   The newly created subsection for ``title``
        :rtype:     ``HelpSection``
        )�_add_sectionrUr^rrrrSszHelpSection.add_sectioncCs(||jkrtd��t|||�|j|<dS)z�Internal method used to add a new subsection to this help output

        :param title:   The title of the subsection being added
        :type title:    ``str`
        z(A section with that title already existsN)rUr/r1r^rrrrbs
zHelpSection._add_sectioncCsdttt|j�t|jd��|j��D]}tt|t|jd��q$|jD]}td�|j|�	�qDdS)zWPrint the HelpSection contents, including any subsections, to
        console.
        )�widthZinitial_indentrN)
r0rrr[�TERMSIZEr]r\�
splitlinesrUr2)rraZsectionrrrr2#s�
zHelpSection.displayN)rrr)T)rr)rr)
rOrVrWrXrr_rRrSrbr2rrrrr1�s




r1)rLr;r,�os�collectionsrZ
sos.componentrZsos.policiesrZsos.report.pluginsrZ
sos.utilitiesrr�textwrapr�min�get_terminal_size�columnsrdr/r
r1rrrr�<module>s 
=