https://t.me/RX1948
Server : nginx/1.24.0
System : Linux ip-172-31-33-48 6.14.0-1011-aws #11~24.04.1-Ubuntu SMP Fri Aug 1 02:07:25 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/reporting/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

x[h$��$�dZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZdZdZd	Zej$e�ZGd
�de�Zed�ZGd
�d�ZGd�de�Zdd�Zej6dfd�Zd�ZGd�d�Zd�Zy)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��eZdZd�Zy)�_namesetc�*�||vr|Std|z��)Nz%s not a valid value)�AttributeError)�self�names  �</usr/lib/python3/dist-packages/cloudinit/reporting/events.py�__getattr__z_nameset.__getattr__ s���4�<��K��3�d�:�;�;�N)�__name__�
__module__�__qualname__r�rrrrs��<rr)�SUCCESS�WARN�FAILc�(�eZdZdZedfd�Zd�Zd�Zy)�ReportingEventz"Encapsulation of event formatting.Nc�v�||_||_||_||_|�t	j�}||_y�N)�
event_typer�description�origin�time�	timestamp)rrrr r!r#s      r�__init__zReportingEvent.__init__,s9��%�����	�&���������	�	��I�"��rc�d�dj|j|j|j�S)z"The event represented as a string.z
{0}: {1}: {2})�formatrrr �rs r�	as_stringzReportingEvent.as_string<s*���%�%��O�O�T�Y�Y��(8�(8�
�	
rc�v�|j|j|j|j|jd�S)z&The event represented as a dictionary.�rr rr!r#r*r's r�as_dictzReportingEvent.as_dictBs3���I�I��+�+��/�/��k�k����
�	
r)rrr�__doc__�DEFAULT_EVENT_ORIGINr$r(r+rrrrr)s��,�$��
#� 
�
rrc�H��eZdZejdf�fd�	Zd�Z�fd�Z�xZS)�FinishReportingEventNc���tt|�t||�||_|�g}||_|tvrtd|z��y)NzInvalid result: %s)�superr/r$�FINISH_EVENT_TYPE�result�
post_files�status�
ValueError)rrr r3r4�	__class__s     �rr$zFinishReportingEvent.__init__NsU���	�"�D�2��t�[�	
�������J�$�������1�F�:�;�;� rc�z�dj|j|j|j|j�S)Nz{0}: {1}: {2}: {3})r&rrr3r r's rr(zFinishReportingEvent.as_string[s0��#�*�*��O�O�T�Y�Y����T�5E�5E�
�	
rc���tt|��}|j|d<|jrt|j�|d<|S)z'The event represented as json friendly.r3�files)r1r/r+r3r4�_collect_file_info)r�datar7s  �rr+zFinishReportingEvent.as_dict`s>����)�4�8�:������X���?�?�.�t���?�D��M��r)	rrrr5rr$r(r+�
__classcell__)r7s@rr/r/Ms ���(.���4�<�
�
�rr/c��|si}tjj�D��chc]\}}||vr|��
}}}ttjj��}|D]!}t
|�|vr�|j|��#ycc}}w)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.
    N)r�registered_items�items�listr�values�type�
publish_event)�event�excluded_handler_types�	hndl_type�hndl_cls�excluded_handler_classes�handlers�handlers       r�report_eventrLis���"�!#��$6�#F�#F�#L�#L�#N� ��I�x��.�.�	� �� �(,�%�6�6�=�=�?�(�H��%����=�4�4�����e�$�%�� s�Bc�6�t||||��}t|�S)zVReport a "finish" event.

    See :py:func:`.report_event` for parameter details.
    �r4)r/rL)�
event_name�event_descriptionr3r4rEs     r�report_finish_eventrQ�s%��
!��%�v�*�
�E����rc�:�tt||�}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_TYPErL)rOrPrEs   r�report_start_eventrT�s��
�+�Z�9J�K�E����rc��eZdZdZdddej
dfd�Zd�Zd�Zd�Z	e
d��Zejd��Ze
d	��Z
e
jd
��Z
d�Zd�Zy)
�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.
    Nc�F�||_||_||_||_||_t
j|_|�g}||_|�|r
|j}nd}||_	|r*dj|j|f�|_i|_y|j|_i|_y)NT�/)
�parentrr �message�result_on_exceptionr5rr3r4�reporting_enabled�join�fullname�children)rrr rZrYr\r[r4s        rr$zReportEventStack.__init__�s��������	�&������#6�� ��n�n������J�$����$��$*�$<�$<�!�$(�!�!2�����H�H��O�O����D�M���
�!�I�I�D�M���
rc�V�d|j�d|j�d|j�d�S)NzReportEventStack(z, z, reporting_enabled=�))rr r\r's r�__repr__zReportEventStack.__repr__�s%���I�I�����"�"�
�	
rc���tj|_|jr t	|j
|j�|jr#d|jj|j<|S)N)NN)
r5rr3r\rTr^r rYr_rr's r�	__enter__zReportEventStack.__enter__�sN���n�n����!�!��t�}�}�d�.>�.>�?��;�;�.:�D�K�K� � ����+��rc���tjtjfD]>}|jj	�D]\}\}}||k(s�||j
fccS�@|j|j
fSr)r5rrr_r@rZr3)r�cand_result�_name�value�_msgs     r�_childrens_finish_infoz'ReportEventStack._childrens_finish_infoso��"�K�K����5�	1�K�(,�
�
�(;�(;�(=�
1�$��}��t��K�'�!�4�<�<�0�0�
1�	1����T�\�\�*�*rc��|jSr)�_resultr's rr3zReportEventStack.results���|�|�rc�>�|tvrtd|z��||_y)Nz'%s' not a valid result)r5r6rl�rrhs  rr3zReportEventStack.results"������6��>�?�?���rc�J�|j�|jS|jSr)�_messager r's rrZzReportEventStack.messages"���=�=�$��=�=� ����rc��||_yr)rprns  rrZzReportEventStack.messages	����
rc�V�|r|j|jfS|j�Sr)r[rZrj)r�excs  r�_finish_infozReportEventStack._finish_infos)����,�,�d�l�l�;�;��*�*�,�,rc���|j|�\}}|jr%||f|jj|j<|jr$t|j|||j��yy)NrN)rtrYr_rr\rQr^r4)r�exc_type�	exc_value�	tracebackr3�msgs      r�__exit__zReportEventStack.__exit__!s`���)�)�)�4�
����;�;�/5�s�m�D�K�K� � ����+��!�!���
�
�s�F�t���
�"r)rrrr,r5rr$rbrdrj�propertyr3�setterrZrtrzrrrrVrV�s���$�T���"�K�K��%�N
��+������]�]����
� �� �

�^�^����-�rrVc��|syg}|D]�}tjj|�sd}ngtjd|���5t|d�5}t
j|j��j�}ddd�ddd�|j|dd����|S#1swY�*xYw#1swY�.xYw)NzReading �rb�base64)�path�content�encoding)�osr��isfiler�Timed�openr�	b64encode�read�decode�append)r:�ret�fnamer��fps     rr;r;+s�����
�C��N���w�w�~�~�e�$��G��"�"�X�e�W�#5�6�
?���t�9�
?�� �*�*�2�7�7�9�5�<�<�>��
?�
?�	�
�
�E�g�8�L�M�N��J�
?�
?��
?�
?�s$�
B9�2B-�B9�-B6�2B9�9C	r) r,r�logging�os.pathr�r"�typingrr
r�cloudinit.reportingrr�cloudinit.reporting.handlersrr2rSr-�	getLoggerr�LOG�setrr5rr/rLrrQrTrVr;rrr�<module>r�s���
������!��:�����"���g����!��<�s�<�
�-�	.��!
�!
�H�>��8%�@+1�.�.�T�
��E�E�P
r

https://t.me/RX1948 - 2025