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/landscape/sysinfo/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/landscape/sysinfo/__pycache__/sysinfo.cpython-310.pyc
o

���c�&�@svddlZddlmZddlZddlZddlmZddlmZddl	m
Z
ddlmZGdd�de
�Z
		
ddd�ZdS)�N)�	getLogger)�Failure)�log_failure)�PluginRegistry)�gather_resultscsheZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
�ZS)�SysInfoPluginRegistryaG
    When the sysinfo plugin registry is run, it will run each of the
    registered plugins so that they get a chance to feed information
    into the registry.

    There are three kinds of details collected: headers, notes, and footnotes.

    They are presented to the user in a way similar to the following:

        Header1: Value1   Header3: Value3
        Header2: Value2   Header4: Value4

        => This is first note
        => This is the second note

        The first footnote.
        The second footnote.

    Headers are supposed to display information which is regularly
    available, such as the load and temperature of the system.  Notes
    contain eventual information, such as warnings of high temperatures,
    and low disk space.  Finally, footnotes contain pointers to further
    information such as URLs.
    cs0tt|���i|_g|_g|_g|_d|_dS)NF)�superr�__init__�
_header_index�_headers�_notes�
_footnotes�
_plugin_error��self��	__class__��;/usr/lib/python3/dist-packages/landscape/sysinfo/sysinfo.pyr	's
zSysInfoPluginRegistry.__init__cCs`|j�|�}|durt|j�|j|<|j�||f�dS|d7}||j|<|j�|||f�dS)ajAdd a new information header to be displayed to the user.

        Header names can be repeated.

        Headers with value None are not returned by get_headers(), but
        they still allocate a position in the list.  This fact may be
        explored to create a deterministic ordering even when dealing
        with values obtained asynchornously.
        N�)r
�get�lenr�append�insert)r�name�value�indexrrr�
add_header/s

z SysInfoPluginRegistry.add_headercCsdd�|jD�S)z�Get all information headers to be displayed to the user.

        Headers which were added with value None are not included in
        the result.
        cSsg|]
}|ddur|�qS)rNr)�.0�pairrrr�
<listcomp>Hsz5SysInfoPluginRegistry.get_headers.<locals>.<listcomp>)rrrrr�get_headersBsz!SysInfoPluginRegistry.get_headerscC�|j�|�dS)z<Add a new eventual note to be shown up to the administrator.N)rr�r�noterrr�add_noteJ�zSysInfoPluginRegistry.add_notecC�|jS)z;Get all eventual notes to be shown up to the administrator.)rrrrr�	get_notesN�zSysInfoPluginRegistry.get_notescCr")z7Add a new footnote to be shown up to the administrator.N)r
rr#rrr�add_footnoteRr&z"SysInfoPluginRegistry.add_footnotecCr')z6Get all footnotes to be shown up to the administrator.)r
rrrr�
get_footnotesVr)z#SysInfoPluginRegistry.get_footnotesc	Cshg}|��D]%}z|��}Wnty|�t�|�Yqw|�|j|�|�|�qt|��|j	�S)z�Run all plugins, and return a deferred aggregating their results.

        This will call the run() method on each of the registered plugins,
        and return a deferred which aggregates each resulting deferred.
        )
�get_plugins�run�	Exception�_log_plugin_errorr�
addErrbackrr�addCallback�_report_error_note)r�	deferreds�plugin�resultrrrr-Zs�zSysInfoPluginRegistry.runcCs,d|_d|jj}td�}t|||d�dS)NTz%s plugin raised an exception.zlandscape-sysinfo)�logger)rr�__name__rr)r�failurer4�messager6rrrr/ksz'SysInfoPluginRegistry._log_plugin_errorcCs4ddlm}|jrtj�|�d�}|�d|�|S)Nr)�get_landscape_log_directoryzsysinfo.logzXThere were exceptions while processing one or more plugins. See %s for more information.)�landscape.sysinfo.deploymentr:r�os�path�joinr%)rr5r:r=rrrr2qs��z(SysInfoPluginRegistry._report_error_note)r7�
__module__�__qualname__�__doc__r	rr!r%r(r*r+r-r/r2�
__classcell__rrrrr
srr�P��   �=> c	sf|t��8}t|�}d}|}	|D]\}
}t|	t|
�t|�d�}	qtt�t|�|	t|���}	tt�|t|���}
g}d}t|�D]F}d}d}t|
�D] }||
|}||kro||\}
}t|t|
��}t|t|��}qO|dkrz|t|�7}|||t|�7}|�||f�qE|dks�||kr�n|d8}q2g}t|
�D]R}�}t|�D]D}||
|}||kr�||\}
}||\}}|dkr�||7}||
|d|t|
�|7}||d|
|kr�|d|t|�7}q�|�|�q�|�r|r�|�d��|}|D]}|�	t
j||dt|�|d���q|�r.|�r"|�d�|�	�fd	d
�|D��d�|�S)a�Format sysinfo headers, notes and footnotes to be displayed.

    This function will format headers notes and footnotes in a way that
    looks similar to the following:

        Header1: Value1   Header3: Value3
        Header2: Value2   Header4: Value4

        => This is first note
        => This is the second note

        The first footnote.
        The second footnote.

    Header columns will be dynamically adjusted to conform to the size
    of header labels and values.
    z: �Trr� rD)�initial_indent�subsequent_indent�widthc3s�|]}�|VqdS)Nr)r�footnote��indentrr�	<genexpr>�s�z!format_sysinfo.<locals>.<genexpr>�
)
r�min�int�math�ceil�float�range�maxr�extend�textwrap�wrapr>)�headers�notes�	footnotesrKrN�column_separator�note_prefix�headers_len�value_separator�
min_length�headerr�columns�headers_per_column�header_lengths�total_length�column�widest_header_len�widest_value_len�row�header_index�lines�linerIr$rrMr�format_sysinfo{s�
�	���.����

��

ro)rrrrCrDrErF)rY�loggingrrSr<�twisted.python.failurer�landscape.lib.logr�landscape.lib.pluginr�landscape.lib.twisted_utilrrrorrrr�<module>sn�

Spamworldpro Mini