Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/sos/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/sos/__pycache__/component.cpython-310.pyc
o

i��d�F�@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZmZGdd�d�ZGd
d�d�ZdS)�N)�SUPPRESS)�datetime)�getpass)�rmtree)�Path)�__version__)�TarFileArchive)�
SoSOptions)�TempFileUtil�	shell_outc
@s�eZdZdZdZiZdZdZdZdZ	dddddddddd	dd
d�Z
dd
�Zdd�Zdd�Z
dd�Zd0dd�Zdd�Zdd�Zedd��Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd1d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�ZdS)2�SoSComponenta�Any sub-command that sos supports needs to subclass SoSComponent in
    order to be properly supported by the sos binary.

    This class contains the standardized entrypoint for subcommands, as well as
    building out supported options from both globally shared option lists, and
    options supported by that specific subcommand.

    When sos initializes, it will load an unintialized instance of each class
    found within one recursion of the module root directory that subclasses
    SoSComponent.

    If sos is able to match the user-specified subcommand to one that exists
    locally, then that SoSComponent is initialized, logging is setup, and a
    policy is loaded. From there, the component's execute() method takes over.

    Added in 4.0
    �unsetTF�autoz/etc/sos/sos.confN��r)�batch�compression_type�config_file�debug�encrypt�encrypt_key�encrypt_pass�quiet�threads�tmp_dir�sysroot�	verbositycCs�||_||_||_d|_d|_d|_d|_d|_zddl}|�|j	|�
��Wn	ty0Ynw|j�
|j�|��|_|jr~|��}t�|_tj�|�rUt�|tj�shd|}|d7}tj�|�|�d�||_tjd|jd�|_t |j�|_|�!�|j"r�|�#�|jdur�|j�$dt%�|j�$d	d
�&|j��|j�$dt'�(��|j�$dd
�|j�$dd
�|j�$dd
�|j�$d|j�|j�$d|j)�|j�$d|j*j+�|j�,d�dSdS)NFrztemporary directory %s z"does not exist or is not writable
�zsos.)�prefix�dir�version�cmdline� �
start_time�end_timer�run_time�compression�tmpdir�tmpdir_fs_type�policy�
components)-�parser�argsr!�exit_process�archiver'�
tempfile_util�manifest�signal�SIGTERM�get_exit_handler�	Exception�
_arg_defaults�update�arg_defaults�load_options�opts�configure_logging�get_tmpdir_default�SoSMetadata�os�path�isdir�access�W_OK�sys�stderr�write�_exit�sys_tmp�tempfile�mkdtempr
�_setup_logging�load_policy�load_local_policy�	add_fieldr�joinr�now�	tmpfstyper)�distro�add_section)�selfr+�parsed_args�cmdline_argsr1r'�msg�rV�//usr/lib/python3/dist-packages/sos/component.py�__init__HsX�
�

�zSoSComponent.__init__cCs\zddl}|jj|jj|jd�|_|jj|_Wnty%|�d�Ynw|j�	�|_
dS)Nr)r�
probe_runtime)�sos.policies�policies�loadr9r�
load_prober)�KeyboardInterruptrE�is_root�_is_root)rR�sosrVrVrWrKs��zSoSComponent.load_local_policycCst��N)�NotImplementedError�rRrVrVrW�execute�szSoSComponent.executecs�fdd�}|S)Ncsd�_���dS)NT)r-rE)�signum�framerdrVrW�exit_handler�sz3SoSComponent.get_exit_handler.<locals>.exit_handlerrV)rRrhrVrdrWr3�szSoSComponent.get_exit_handlercCs$|r|j�d�|j�|�t|��)Nr)�ui_log�error�
SystemExit)rRrjrUrVrVrWrE�szSoSComponent._exitcCs�|jjr
tj�|jj�}nt�dd�pd}t�dd�r.t�dd�r.tj�t�d�|�d��}tdd|f��	�|_
|j
d	krGtd
�t�
d�|S)z�If --tmp-dir is not specified, provide a default location.
        Normally this is /var/tmp, but if we detect we are in a container, then
        use a standardized env var to redirect to the host's filesystem instead
        �TMPDIRNz/var/tmp�HOST�	container�/z!stat --file-system --format=%s %sz%T�tmpfsz�WARNING: tmp-dir is set to a tmpfs filesystem. This may increase memory pressure and cause instability on low memory systems, or when using --all-logs.�)r9rr=r>�abspath�getenvrM�lstripr�striprO�print�time�sleep)rRr'rVrVrWr;�s
��

zSoSComponent.get_tmpdir_defaultcs6dd��j����D�}|rt�fdd�|D��SdS)NcSsg|]	}|�d�r|�qS)�list)�
startswith)�.0�orVrVrW�
<listcomp>�sz6SoSComponent.check_listing_options.<locals>.<listcomp>csg|]}t�j|��qSrV)�getattrr9)r{�optrdrVrWr}�s)r9�dict�keys�any)rRr9rVrdrW�check_listing_options�s�z"SoSComponent.check_listing_optionscCsdS)ziThis should be overridden by each subcommand to add its own unique
        options to the parser
        NrV)�clsr+rVrVrW�add_parser_options�szSoSComponent.add_parser_optionsc	s�t�j|j�|j�|jdd�d�}|jdd�}|��D]F\}}||j��vs-|dgdfvr.q|dvrTdD]}t	|�t	t
||��@��rSt||�fdd�t
||�D��q4||j|krat|||�q|S)	a.(Re-)apply options specified via the cmdline to an options instance

        There are several cases where we may need to re-apply the options from
        the cmdline over previously loaded options - for instance when an
        option is specified in both a config file and cmdline, or a preset and
        the cmdline, or all three.

        Use this to re-apply cmdline option overrides to anything that may
        change the default values of options

        Positional arguments:

            :param opts:        SoSOptions object to update

        F)�
preset_filter�r7Nr)�enable_plugins�skip_plugins�only_pluginscsg|]}|�vr|�qSrVrV)r{�x��commonrVrWr}�s�z;SoSComponent.apply_options_from_cmdline.<locals>.<listcomp>)r	�	from_argsr+�
parse_argsr!r��itemsr7r��setr~�setattr)rRr9�cmdopts�codictr�val�ooptrVr�rW�apply_options_from_cmdline�s$
� ��z'SoSComponent.apply_options_from_cmdlinecCs�t|jd�}|jjD]
}|jtkrd|_q
|�|jj|jj	�d|j
vs)d|j
vr1|�|jjd�t��dkrNtj
�t��d�}tj
�|�rN|�||jj	�|�|�}|S)zxCompile arguments loaded from defaults, config files, and the
        command line into a usable set of options
        r�Nz--cleanz--mask�cleanrz.config/sos/sos.conf)r	r5r+�_actions�defaultr�update_from_confr,r�	componentr!r=�getuidr>rMr�home�existsr�)rRr9�option�userconfrVrVrWr8�s
�
zSoSComponent.load_optionsc
Csvz|jr	|j��|jr|j��|jrt|j�WdSWdSty:}ztd||jf�WYd}~dSd}~ww)Nz6Failed to finish cleanup: %s
Contents may remain in %s)r.�cleanupr/r�r'rr4rv)rR�errrVrVrWr�
s

����zSoSComponent.cleanupcCsbd}tj�d�rtj�d�|j_d}ntj�d�r#tj�d�|j_d}|j�|�|j�|�dS)NzFNo encryption environment variables set, archive will not be encrypted�
SOSENCRYPTKEYz+Encryption key set via environment variable�SOSENCRYPTPASSz2Encryption passphrase set via environment variable)	r=�environ�getr9rr�soslog�infori)rRrUrVrVrW�_set_encrypt_from_env_varssz'SoSComponent._set_encrypt_from_env_varscCs�|jjsLd}|dvrtd���}|dvs
|dkr td�|j_dS|dkr,td�|j_dS|dkr6|��dSd|j_d|j_|j�	d�|j
�d	�dS|��dS)
N)�P�K�E�NzLSpecify encryption method [P]assphrase, [K]ey, [E]nv vars, [N]o encryption: r�zSpecify encryption passphrase: r�zSpecify encryption key: r�z@User specified --encrypt, but chose no encryption when prompted.zArchive will not be encrypted)r9r�input�upperrrrr�r�r�ri�warning)rR�_encrVrVrW�_get_encryption_method's(���z#SoSComponent._get_encryption_methodcCs�|jjr|��|jjs|jjrdnd|jj|jjd�}|s#|j��}tj�	|j
|�}|jjdkrH|j��}|||j
|j|jj
||j|j�|_nt||j
|j|jj
||j|j�|_|j�|jjdk�dS)NTF)r�key�passwordrrq)r9rr�rrr)�get_archive_namer=r>rMr'r�get_preferred_archiverrr0r.r�	set_debugr)rR�name�enc_opts�archive_name�auto_archiverVrVrW�
setup_archive?s2��


�
�zSoSComponent.setup_archivecCsJt�tj�}|�t�d��|�|jjdkrtj	ntj
�|j�|�dS)N�%(message)sr)
�logging�
StreamHandlerrB�stdout�setFormatter�	Formatter�setLevelr9r�DEBUG�INFOri�
addHandler)rR�
ui_consolerVrVrW�add_ui_log_to_stdoutZs�z!SoSComponent.add_ui_log_to_stdoutcCsZ|r$|jr|j�tj�|jjdkr|j�tj�dS|j�tj�dS|j�tj�dS�Nr)�flogr�r�r�r9r�console�WARNING)rRrrVrVrW�set_loggers_verbositybsz"SoSComponent.set_loggers_verbositycCsft�d�|_|j�tj�d|_|��s7|��|_t�	|j�|_|j�
t�d��|j�tj�|j�
|j�|jjsZt�	tj�|_|j�
t�d��|�|jj�|j�
|j�nt�	tj�}|�
t�d��|�tj�|j�
|�t�d�|_|j�|jjdkr�tjntj�|��s�|��|_t�	|j�}|�
t�d��|j�
|�|jjs�|��dSdS)z�Creates the log handler that shall be used by all components and any
        and all related bits to those components that need to log either to the
        console or to the log file for that run of sos.
        raNz&%(asctime)s %(levelname)s: %(message)sr��sos_uir)r��	getLoggerr�r�r�r�r��
get_temp_file�sos_log_filer�r�r�r�r�r9rrBr�r�r�rrC�ERRORri�sos_ui_log_filer�)rR�console_err�ui_fhandlerrVrVrWrImsD

��
��zSoSComponent._setup_loggingcCs
|j��Srb)r/�newrdrVrVrWr���
zSoSComponent.get_temp_file)rN)r)�__name__�
__module__�__qualname__�__doc__�descr7r:rJr]�
root_requiredr5rXrKrer3rEr;r��classmethodr�r�r8r�r�r�r�r�r�rIr�rVrVrVrWrsP�7


/
.rc@sVeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	gfdd�Z
ddd�ZdS)r<a8This class is used to record metadata from a sos execution that will
    then be stored as a JSON-formatted manifest within the final tarball.

    It can be extended by adding further instances of SoSMetadata to represent
    dict-like structures throughout the various sos bits that record to
    metadata
    cCs
i|_dSrb��_valuesrdrVrVrWrX�r�zSoSMetadata.__init__ccs �|j��D]}|dVqdSr�)r�r��rR�itemrVrVrW�__iter__�s��zSoSMetadata.__iter__cCs
|j|Srbr�r�rVrVrW�__getitem__�r�zSoSMetadata.__getitem__cCs$z|j|WStyt|��wrb)r�r4�AttributeError)rR�attrrVrVrW�__getattr__�s
�zSoSMetadata.__getattr__cCs||j|<dS)z@Add a key, value entry to the current metadata instance
        Nr�)rR�
field_name�contentrVrVrWrL�szSoSMetadata.add_fieldcCst�|j|<|j|S)zCAdds a new instance of SoSMetadata to the current instance
        )r<r�)rR�section_namerVrVrWrQ�s
zSoSMetadata.add_sectioncCs t|t�s	td��||j|<dS)z�Add a named list element to the current instance. If content is not
        supplied, then add an empty list that can alter be appended to
        zcontent added must be listN)�
isinstancery�	TypeErrorr�)rR�	list_namer�rVrVrW�add_list�s
zSoSMetadata.add_listNcCstj|dd�|d�S)z�Convert contents of this SoSMetdata instance, and all other nested
        instances (sections), into a json-formatted output.

        Used to write manifest.json to the final archives.
        cSst|dt|��S)Nr�)r~�str)r|rVrVrW�<lambda>�sz&SoSMetadata.get_json.<locals>.<lambda>)r��indent)�json�dumps)rRr�rVrVrW�get_json�s�zSoSMetadata.get_jsonrb)r�r�r�r�rXr�r�r�rLrQr�r�rVrVrVrWr<�sr<)r�r�r=rGrBrw�argparserrr�shutilr�pathlibrrar�sos.archiver�sos.optionsr	�
sos.utilitiesr
rrr<rVrVrVrW�<module>s(

Spamworldpro Mini