403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/reporting/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/reporting/__pycache__/events.cpython-36.opt-1.pyc
3

��b#�@s�dZddlZddlZddlZddlmZmZdZdZ	dZ
Gdd	�d	e�Zed�Z
Gd
d�de�ZGdd�de�Zddd�Ze
jdfdd�Zdd�ZGdd�de�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�)�available_handlers�instantiated_handler_registryZfinish�startZ	cloudinitc@seZdZdd�ZdS)�_namesetcCs||kr|Std|��dS)Nz%s not a valid value)�AttributeError)�self�name�r
�/usr/lib/python3.6/events.py�__getattr__sz_nameset.__getattr__N)�__name__�
__module__�__qualname__rr
r
r
rrsr�SUCCESS�WARN�FAILc@s.eZdZdZedfdd�Zdd�Zdd�ZdS)	�ReportingEventz"Encapsulation of event formatting.NcCs2||_||_||_||_|dkr(tj�}||_dS)N)�
event_typer	�description�origin�time�	timestamp)rrr	rrrr
r
r�__init__$szReportingEvent.__init__cCsdj|j|j|j�S)z"The event represented as a string.z
{0}: {1}: {2})�formatrr	r)rr
r
r�	as_string4szReportingEvent.as_stringcCs|j|j|j|j|jd�S)z&The event represented as a dictionary.)r	rrrr)r	rrrr)rr
r
r�as_dict:s
zReportingEvent.as_dict)r
rr�__doc__�DEFAULT_EVENT_ORIGINrrrr
r
r
rr!s

rcs8eZdZejdf�fdd�	Zdd�Z�fdd�Z�ZS)�FinishReportingEventNcsDtt|�jt||�||_|dkr&g}||_|tkr@td|��dS)NzInvalid result: %s)�superrr�FINISH_EVENT_TYPE�result�
post_files�status�
ValueError)rr	rr"r#)�	__class__r
rrFs

zFinishReportingEvent.__init__cCsdj|j|j|j|j�S)Nz{0}: {1}: {2}: {3})rrr	r"r)rr
r
rrSszFinishReportingEvent.as_stringcs0tt|�j�}|j|d<|jr,t|j�|d<|S)z'The event represented as json friendly.r"�files)r rrr"r#�_collect_file_info)r�data)r&r
rrXs

zFinishReportingEvent.as_dict)	r
rrr$rrrr�
__classcell__r
r
)r&rrEsrcsX�si��fdd�tjj�D�}tjj�}x(|D] \}}t|�|krFq0|j|�q0WdS)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|]\}}|�kr|�qSr
r
)�.0Z	hndl_typeZhndl_cls)�excluded_handler_typesr
r�	<setcomp>qszreport_event.<locals>.<setcomp>N)rZregistered_items�itemsr�typeZ
publish_event)�eventr,Zexcluded_handler_classesZhandlers�_Zhandlerr
)r,r�report_eventas

r2cCst||||d�}t|�S)zVReport a "finish" event.

    See :py:func:`.report_event` for parameter details.
    )r#)rr2)�
event_name�event_descriptionr"r#r0r
r
r�report_finish_event~sr5cCstt||�}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_TYPEr2)r3r4r0r
r
r�report_start_event�s
r7c@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|_|dkr2g}||_|dkrP|rL|j	}nd}||_	|rndj
|j|f�|_n|j|_i|_dS)NT�/)
�parentr	r�message�result_on_exceptionr$rr"r#�reporting_enabled�join�fullname�children)rr	rr;r:r=r<r#r
r
rr�s(
zReportEventStack.__init__cCsd|j|j|jfS)Nz.ReportEventStack(%s, %s, reporting_enabled=%s))r	rr=)rr
r
r�__repr__�szReportEventStack.__repr__cCs4tj|_|jrt|j|j�|jr0d|jj|j	<|S)N)NN)
r$rr"r=r7r?rr:r@r	)rr
r
r�	__enter__�szReportEventStack.__enter__cCsPxBtjtjfD]2}x,|jj�D]\}\}}||kr||jfSqWqW|j|jfS)N)r$rrr@r.r;r")rZcand_result�_name�valueZ_msgr
r
r�_childrens_finish_info�s
z'ReportEventStack._childrens_finish_infocCs|jS)N)�_result)rr
r
rr"�szReportEventStack.resultcCs|tkrtd|��||_dS)Nz'%s' not a valid result)r$r%rF)rrDr
r
rr"scCs|jdk	r|jS|jS)N)�_messager)rr
r
rr;s
zReportEventStack.messagecCs
||_dS)N)rG)rrDr
r
rr;
scCs|r|j|jfS|j�S)N)r<r;rE)r�excr
r
r�_finish_infoszReportEventStack._finish_infocCsD|j|�\}}|jr&||f|jj|j<|jr@t|j|||jd�dS)N)r#)rIr:r@r	r=r5r?r#)r�exc_type�	exc_value�	tracebackr"�msgr
r
r�__exit__szReportEventStack.__exit__)r
rrrr$rrrArBrE�propertyr"�setterr;rIrNr
r
r
rr8�s%r8c
Csj|sdSg}xX|D]P}tjj|�s(d}n(t|d��}tj|j��j�}WdQRX|j||dd��qW|S)N�rb�base64)�path�content�encoding)	�osrS�isfile�openrRZ	b64encode�read�decode�append)r'�retZfnamerT�fpr
r
rr(!s
r()rrr)N)rrRZos.pathrVr�rrr!r6r�setrr$�objectrrr2rr5r7r8r(r
r
r
r�<module>
s"$
	

Youez - 2016 - github.com/yon3zu
LinuXploit