403Webshell
Server IP : 167.99.254.82  /  Your IP : 216.73.216.252
Web Server : Apache
System : Linux host.techisquad.com 5.15.0-187-generic #197-Ubuntu SMP Fri Jul 17 19:17:01 UTC 2026 x86_64
User : pawluxera ( 1011)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/cloudinit/reporting/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit/reporting/__pycache__/events.cpython-310.pyc
o

��im&�@s�dZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZdZdZd	Ze�e�ZGd
d�de�Zed�ZGd
d�d�ZGdd�de�Zddd�Zejdfdd�Zdd�ZGdd�d�Zdd�ZdS)z�
events for reporting.

The events here are designed to be used with reporting.
They can be published to registered handlers with report_event.
�N)�List)�performance)�available_handlers�instantiated_handler_registry)�ReportingHandler�finish�start�	cloudinitc@seZdZdd�ZdS)�_namesetcCs||vr|Std|��)Nz%s not a valid value)�AttributeError)�self�name�r�</usr/lib/python3/dist-packages/cloudinit/reporting/events.py�__getattr__ sz_nameset.__getattr__N)�__name__�
__module__�__qualname__rrrrrr
sr
)�SUCCESS�WARN�FAILc@s.eZdZdZedfdd�Zdd�Zdd�ZdS)	�ReportingEventz"Encapsulation of event formatting.NcCs2||_||_||_||_|durt��}||_dS�N)�
event_typer
�description�origin�time�	timestamp)rrr
rrrrrr�__init__,s
zReportingEvent.__init__cCsd�|j|j|j�S)z"The event represented as a string.z
{0}: {1}: {2})�formatrr
r�rrrr�	as_string<s�zReportingEvent.as_stringcCs|j|j|j|j|jd�S)z&The event represented as a dictionary.�r
rrrrr"r rrr�as_dictBs�zReportingEvent.as_dict)rrr�__doc__�DEFAULT_EVENT_ORIGINrr!r#rrrrr)s
�rcs8eZdZejdf�fdd�	Zdd�Z�fdd�Z�ZS)�FinishReportingEventNcsJtt|��t||�||_|durg}||_||_|tvr#td|��dS)NzInvalid result: %s)	�superr&r�FINISH_EVENT_TYPE�result�
post_files�duration�status�
ValueError)rr
rr+r)r*��	__class__rrrNs
��zFinishReportingEvent.__init__cCsd�|j|j|j|j|j�S)Nz'{0}: {1}: {2}: {3} (duration: {4:.3f}s))rrr
r)rr+r rrrr!as�zFinishReportingEvent.as_stringcs@tt|���}|j|d<t|jd�|d<|jrt|j�|d<|S)z'The event represented as json friendly.r)�r+�files)r'r&r#r)�roundr+r*�_collect_file_info)r�datar.rrr#js
zFinishReportingEvent.as_dict)	rrrr,rrr!r#�
__classcell__rrr.rr&Ms�	r&csT�si��fdd�tj��D�}ttj���}|D]}t|�|vr"q|�|�qdS)a�Report an event to all registered event handlers
    except those whose type is in excluded_handler_types.

    This should generally be called via one of the other functions in
    the reporting module.

    :param excluded_handler_types:
         List of handlers types to exclude from reporting the event to.
    :param event_type:
        The type of the event; this should be a constant from the
        reporting module.
    csh|]
\}}|�vr|�qSrr)�.0�	hndl_type�hndl_cls��excluded_handler_typesrr�	<setcomp>�s
�zreport_event.<locals>.<setcomp>N)r�registered_items�items�listr�values�type�
publish_event)�eventr:�excluded_handler_classes�handlers�handlerrr9r�report_eventts
���rFcCst|||||d�}t|�S)zVReport a "finish" event.

    See :py:func:`.report_event` for parameter details.
    )r*)r&rF)�
event_name�event_descriptionr+r)r*rBrrr�report_finish_event�s
�rIcCstt||�}t|�S)a'Report a "start" event.

    :param event_name:
        The name of the event; this should be a topic which events would
        share (e.g. it will be the same for start and finish events).

    :param event_description:
        A human-readable description of the event that has occurred.
    )r�START_EVENT_TYPErF)rGrHrBrrr�report_start_event�s
rKc@s�eZdZdZdddejdfdd�Zdd�Zdd�Zd	d
�Z	e
dd��Zejd
d��Ze
dd��Z
e
jdd��Z
dd�Zdd�ZdS)�ReportEventStackaKContext Manager for using :py:func:`report_event`

    This enables calling :py:func:`report_start_event` and
    :py:func:`report_finish_event` through a context manager.

    :param name:
        the name of the event

    :param description:
        the event's description, passed on to :py:func:`report_start_event`

    :param message:
        the description to use for the finish event. defaults to
        :param:description.

    :param parent:
    :type parent: :py:class:ReportEventStack or None
        The parent of this event.  The parent is populated with
        results of all its children.  The name used in reporting
        is <parent.name>/<name>

    :param reporting_enabled:
        Indicates if reporting events should be generated.
        If not provided, defaults to the parent's value, or True if no parent
        is provided.

    :param result_on_exception:
        The result value to set if an exception is caught. default
        value is FAIL.

    :param post_files:
        Can hold filepaths of files that are to get posted/created
        regarding a given event. Something like success or failure information
        in a given log file. For each filepath, if it's a valid regular file
        it will get: read & encoded as base64 at the close of the event.
        Default value, if None, is an empty list.
    NcCs�||_||_||_||_||_tj|_d|_|durg}||_	|dur+|r)|j
}nd}||_
|r:d�|j|f�|_n|j|_i|_
dS)NT�/)�parentr
r�message�result_on_exceptionr,rr)�start_timestampr*�reporting_enabled�join�fullname�children)rr
rrOrNrRrPr*rrrr�s.
��
zReportEventStack.__init__cCsd|j|j|jfS)Nz.ReportEventStack(%s, %s, reporting_enabled=%s))r
rrRr rrr�__repr__s
�zReportEventStack.__repr__cCs>tj|_t��|_|jrt|j|j	�|j
rd|j
j|j<|S)N)NN)
r,rr)r�	monotonicrQrRrKrTrrNrUr
r rrr�	__enter__s
zReportEventStack.__enter__cCsPtjtjfD]}|j��D]\}\}}||kr ||jfSq
q|j|jfSr)r,rrrUr=rOr))r�cand_result�_name�value�_msgrrr�_childrens_finish_infos��z'ReportEventStack._childrens_finish_infocCs|jSr)�_resultr rrrr)szReportEventStack.resultcCs|tvr
td|��||_dS)Nz'%s' not a valid result)r,r-r^�rr[rrrr)s
cCs|jdur|jS|jSr)�_messagerr rrrrO"s
zReportEventStack.messagecCs
||_dSr)r`r_rrrrO(s
cCs|r|j|jfS|��Sr)rPrOr])r�excrrr�_finish_info,szReportEventStack._finish_infocCsh|�|�\}}|jr||f|jj|j<|jr2|jdur#t��|j}nd}t|j	||||j
d�dSdS)Ng)r+r)r*)rbrNrUr
rRrQrrWrIrTr*)r�exc_type�	exc_value�	tracebackr)�msgr+rrr�__exit__2s

��zReportEventStack.__exit__)rrrr$r,rrrVrXr]�propertyr)�setterrOrbrgrrrrrL�s**
�(	



rLc
Cs�|sdSg}|D]J}tj�|�sd}n6t�d|����&t|d��}t�|����	�}Wd�n1s5wYWd�n1sDwY|�
||dd��q|S)NzReading �rb�base64)�path�content�encoding)�osrl�isfiler�Timed�openrk�	b64encode�read�decode�append)r1�ret�fnamerm�fprrrr3Ds ���r3r) r$rk�logging�os.pathror�typingrr	r�cloudinit.reportingrr�cloudinit.reporting.handlersrr(rJr%�	getLoggerr�LOG�setr
r,rr&rFrrIrKrLr3rrrr�<module>s2
$
'#
�

Youez - 2016 - github.com/yon3zu
LinuXploit