HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1991111/cwd/lib/python3/dist-packages/cloudinit/reporting/__pycache__/
Upload File :
Current File : //proc/1991111/cwd/lib/python3/dist-packages/cloudinit/reporting/__pycache__/events.cpython-311.pyc
�

܍~c�#���dZddlZddlZddlZddlmZddlmZm	Z	ddl
mZdZdZ
dZGd	�d
e��Zed��ZGd�d
��ZGd�de��Zdd�Zejdfd�Zd�ZGd�d��Zd�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)�available_handlers�instantiated_handler_registry)�ReportingHandler�finish�start�	cloudinitc��eZdZd�ZdS)�_namesetc�2�||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�rrrrs#������<�<�<�<�<rr)�SUCCESS�WARN�FAILc�*�eZdZdZedfd�Zd�Zd�ZdS)�ReportingEventz"Encapsulation of event formatting.Nc�v�||_||_||_||_|�t	j��}||_dS�N)�
event_typer�description�origin�time�	timestamp)rrrrr r"s      r�__init__zReportingEvent.__init__)s=��%�����	�&���������	���I�"����rc�N�d�|j|j|j��S)z"The event represented as a string.z
{0}: {1}: {2})�formatrrr�rs r�	as_stringzReportingEvent.as_string9s(���%�%��O�T�Y��(8�
�
�	
rc�D�|j|j|j|j|jd�S)z&The event represented as a dictionary.�rrrr r"r)r&s r�as_dictzReportingEvent.as_dict?s-���I��+��/��k���
�
�	
r)rrr�__doc__�DEFAULT_EVENT_ORIGINr#r'r*rrrrr&sT������,�,�$��
#�#�#�#� 
�
�
�
�
�
�
�
rrc�>��eZdZejdf�fd�	Zd�Z�fd�Z�xZS)�FinishReportingEventNc���tt|���t||��||_|�g}||_|tvrtd|z���dS)NzInvalid result: %s)�superr.r#�FINISH_EVENT_TYPE�result�
post_files�status�
ValueError)rrrr2r3�	__class__s     �rr#zFinishReportingEvent.__init__Ksq���	�"�D�)�)�2�2��t�[�	
�	
�	
�������J�$��������1�F�:�;�;�;� �rc�Z�d�|j|j|j|j��S)Nz{0}: {1}: {2}: {3})r%rrr2rr&s rr'zFinishReportingEvent.as_stringXs,��#�*�*��O�T�Y���T�5E�
�
�	
rc���tt|�����}|j|d<|jrt|j��|d<|S)z'The event represented as json friendly.r2�files)r0r.r*r2r3�_collect_file_info)r�datar6s  �rr*zFinishReportingEvent.as_dict]sM����)�4�0�0�8�8�:�:�����X���?�	@�.�t��?�?�D��M��r)	rrrr4rr#r'r*�
__classcell__)r6s@rr.r.Jsl�������(.��4�<�<�<�<�<�<�
�
�
�
��������rr.c����si��fd�tj���D��}ttj�����}|D])}t
|��|vr�|�|���*dS)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.
    c�"��h|]\}}|�v�	|��Srr)�.0�	hndl_type�hndl_cls�excluded_handler_typess   �r�	<setcomp>zreport_event.<locals>.<setcomp>vs3��� � � ��I�x��.�.�.�	�.�.�.rN)r�registered_items�items�listr�values�type�
publish_event)�eventrB�excluded_handler_classes�handlers�handlers `   r�report_eventrNfs����"�$�!#�� � � � �#5�#F�#L�#L�#N�#N� � � ��(,�%�6�=�=�?�?�(�(�H��%�%����=�=�4�4�4�����e�$�$�$�$�%�%rc�F�t||||���}t|��S)zVReport a "finish" event.

    See :py:func:`.report_event` for parameter details.
    �r3)r.rN)�
event_name�event_descriptionr2r3rJs     r�report_finish_eventrS�s2��
!��%�v�*�
�
�
�E�����rc�L�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_TYPErN)rQrRrJs   r�report_start_eventrV�s%��
�+�Z�9J�K�K�E�����rc��eZdZdZdddejdfd�Zd�Zd�Zd�Z	e
d���Zejd���Ze
d	���Z
e
jd
���Z
d�Zd�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.
    Nc��||_||_||_||_||_t
j|_|�g}||_|�|r|j	}nd}||_	|r"d�
|j|f��|_n|j|_i|_dS)NT�/)
�parentrr�message�result_on_exceptionr4rr2r3�reporting_enabled�join�fullname�children)rrrr\r[r^r]r3s        rr#zReportEventStack.__init__�s��������	�&������#6�� ��n������J�$����$��
)�$*�$<�!�!�$(�!�!2����	&��H�H��O�����D�M�M�!�I�D�M���
�
�
rc�8�d|j�d|j�d|j�d�S)NzReportEventStack(z, z, reporting_enabled=�))rrr^r&s r�__repr__zReportEventStack.__repr__�s/����I�I�I������"�"�"�
�	
rc��tj|_|jrt	|j|j��|jrd|jj|j	<|S)N)NN)
r4rr2r^rVr`rr[rarr&s r�	__enter__zReportEventStack.__enter__�sL���n����!�	@��t�}�d�.>�?�?�?��;�	;�.:�D�K� ���+��rc��tjtjfD]7}|j���D]\}\}}||kr
||jfccS��8|j|jfSr)r4rrrarEr\r2)r�cand_result�_name�value�_msgs     r�_childrens_finish_infoz'ReportEventStack._childrens_finish_info�s��"�K���5�	1�	1�K�(,�
�(;�(;�(=�(=�
1�
1�$��}��t��K�'�'�!�4�<�0�0�0�0�0�0�(�
1���T�\�*�*rc��|jSr)�_resultr&s rr2zReportEventStack.results
���|�rc�J�|tvrtd|z���||_dS)Nz'%s' not a valid result)r4r5rn�rrjs  rr2zReportEventStack.results,�������6��>�?�?�?�����rc�,�|j�|jS|jSr)�_messagerr&s rr\zReportEventStack.messages���=�$��=� ���rc��||_dSr)rrrps  rr\zReportEventStack.messages
����
�
�
rc�J�|r|j|jfS|���Sr)r]r\rl)r�excs  r�_finish_infozReportEventStack._finish_infos,���	<��,�d�l�;�;��*�*�,�,�,rc��|�|��\}}|jr||f|jj|j<|jrt|j|||j���dSdS)NrP)rvr[rarr^rSr`r3)r�exc_type�	exc_value�	tracebackr2�msgs      r�__exit__zReportEventStack.__exit__s{���)�)�)�4�4�
����;�	<�/5�s�m�D�K� ���+��!�	���
�s�F�t��
�
�
�
�
�
�	�	r)rrrr+r4rr#rdrfrl�propertyr2�setterr\rvr|rrrrXrX�s������$�$�T���"�K��%�%�%�%�N
�
�
����+�+�+�����X���]����]��
� � ��X� �

�^����^��-�-�-�����rrXc�R�|sdSg}|D]�}tj�|��sd}n`t|d��5}t	j|��������}ddd��n#1swxYwY|�||dd�����|S)N�rb�base64)�path�content�encoding)	�osr��isfile�openr��	b64encode�read�decode�append)r9�ret�fnamer��fps     rr:r:(s������t�
�C��N�N���w�~�~�e�$�$�	?��G�G��e�T�"�"�
?�b� �*�2�7�7�9�9�5�5�<�<�>�>��
?�
?�
?�
?�
?�
?�
?�
?�
?�
?�
?����
?�
?�
?�
?��
�
�E�g�8�L�L�M�M�M�M��Js�9B�B	�	B	r)r+r��os.pathr�r!�typingr�cloudinit.reportingrr�cloudinit.reporting.handlersrr1rUr,�setrr4rr.rNrrSrVrXr:rrr�<module>r�s���
���
�
�
�����������������������:�9�9�9�9�9�����"��<�<�<�<�<�s�<�<�<�
��-�	.�	.��!
�!
�!
�!
�!
�!
�!
�!
�H�����>����8%�%�%�%�@+1�.�T�
�
�
�
����E�E�E�E�E�E�E�E�P����r