HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/__pycache__/client.cpython-37.pyc
B

Ta�6�@s�ddlZddlZddlZddlmZddlZddlmZmZmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZddlmZddlmZmZmZddlmZdd	l	mZdd
lmZddlm Z ddl!m"Z"e"�r.dd
l#m$Z$ddl#m%Z%ddl#m&Z&ddl#m'Z'ddl(m)Z)ddl!m*Z*m+Z+ddl,m-Z-ed�Z.dd�Z/Gdd�de0�Z1ddl!m"Z"e"�r�Gdd�dee&e2e$f�Z3Gdd�dee1�Z4ndd��Z3dd��Z4dS) �N)�datetime)�string_types�	text_type�	iteritems)�capture_internal_exceptions�current_stacktrace�disable_capture_event�format_timestamp�
get_type_name�get_default_release�
handle_in_app�logger)�	serialize)�make_transport)�DEFAULT_OPTIONS�SDK_INFO�ClientConstructor)�setup_integrations)�
ContextVar)�SessionFlusher)�Envelope)�MYPY)�Any)�Callable)�Dict)�Optional)�Scope)�Event�Hint)�SessionZclient_init_debugcOs|r:t|dtttf�s$|ddkr:|d}|dd�}nd}tt�}t||�}|dk	rn|�d�dkrn||d<x2t|�D]&\}}||kr�td|f��|||<qxW|ddkr�t	j
�d�|d<|ddkr�t�|d<|ddkr�t	j
�d�p�d	|d<|d
dk�rtt
d��rt
��|d
<|S)Nr��dsnzUnknown option %rZ
SENTRY_DSN�release�environmentZSENTRY_ENVIRONMENT�
production�server_name�gethostname)�
isinstancer�bytes�str�dictr�getr�	TypeError�os�environr�hasattr�socketr&)�args�kwargsr!�rv�options�key�value�r7�B/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/client.py�_get_options*s*$

r9c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
�Z
dd�Zd!dd�Zdd�Z
d"dd�Zdd�Zd#dd�Zd$dd�Zdd�Zdd �ZdS)%�_Clientz�The client is internally responsible for capturing the events and
    forwarding them to sentry through the configured transport.  It takes
    the client options as keyword arguments and optionally the DSN as first
    argument.
    cOst||�|_|��dS)N)�get_optionsr4�
_init_impl)�selfr1r2r7r7r8�__init__Rsz_Client.__init__cCs
d|jiS)Nr4)r4)r=r7r7r8�__getstate__Wsz_Client.__getstate__cCs|d|_|��dS)Nr4)r4r<)r=�stater7r7r8�__setstate__[s
z_Client.__setstate__c	s�t�d�}�fdd�}znt��jd�t�j��_t|d��_d}�jd|kr`td�	|���t
�jd	�jd
�jdd��_Wdt�|�XdS)
NFcs�jdk	r�j�|�dS)N)�	transport�capture_envelope)�envelope)r=r7r8�_capture_envelopeds
z-_Client._init_impl.<locals>._capture_envelope�debug)Zcapture_func)�always�neverZsmallZmedium�request_bodiesz3Invalid value for request_bodies. Must be one of {}�integrationsZdefault_integrationsZauto_enabling_integrations)Z
with_defaultsZwith_auto_enabling_integrations)�_client_init_debugr+�setr4rrBr�session_flusher�
ValueError�formatrrJ)r=Z	old_debugrErIr7)r=r8r<`s"
z_Client._init_implcCs
|jdS)z%Returns the configured DSN as string.r!)r4)r=r7r7r8r!�sz_Client.dsnc		Cs�|�d�dkrt��|d<|dk	r>|�||�}|dkr:dS|}|jdr�d|kr�d|kr�d|kr�t��&dt|jd�dd	d
�gi|d<WdQRXx>dD]6}|�|�dkr�|j|dk	r�t|j|���||<q�W|�d�dk�rt	t
�}t|j�
��|d
<||d<|�d�dk�rd|d<t||jd|jd�}|dk	�rVt||jd�d�d�}|jd}|dk	�r�|�d�dk�r�d}t��|||�p�i�}WdQRX|dk�r�t�d|�|}|S)N�	timestampZattach_stacktrace�	exception�
stacktrace�threads�valuesZwith_localsFT)rR�crashed�current)r"r#r%�distZsdkrJ�platform�pythonZin_app_excludeZin_app_includeZ_experiments�smart_transaction_trimming)rZ�before_send�type�transactionzbefore send dropped event (%s))r+r�utcnowZapply_to_eventr4rrr�stripr*r�sortedrJ�keysrrr
�info)	r=�event�hint�scopeZevent_r5Zsdk_infor[Z	new_eventr7r7r8�_prepare_event�sT







z_Client._prepare_eventcCs~|�d�}|dkrdSt|d�}d|dj|f}xD|jdD]6}t|t�rd||ks^||krvdSq@t|d|�r@dSq@WdS)N�exc_infoFrz%s.%s�
ignore_errorsT)r+r
�
__module__r4r'r�
issubclass)r=rcrdrgZ	type_name�	full_nameZerrclsr7r7r8�_is_ignored_error�s

z_Client._is_ignored_errorNcCs\|�d�dkrdS|dk	r$|js$dS|jddkrHt��|jdkrHdS|�||�rXdSdS)Nr\r]TFZsample_rateg�?)r+�_should_capturer4�randomrl)r=rcrdrer7r7r8rm�sz_Client._should_capturec
Cs�d}d}d}|�d�pi�d�}|rXd}x.|D]&}|�d�}|r.|�d�dkr.d}Pq.W|�d�}	|jdkr�|�d�pxi�d	�}
x*t|
p�i�D]\}}|��d
kr�|}Pq�W|j|r�dnd|	||j|p�|d�dS)
NFrQrTT�	mechanismZhandled�userZrequest�headersz
user-agentrU)�statusrp�
user_agent�errors)r+rsr�lower�updatert)
r=�sessionrcrUZerroredrs�
exceptions�errorrorprq�k�vr7r7r8�_update_session_from_event�s.




z"_Client._update_session_from_eventcCs<t�d�rdS|jdkrdS|dkr(i}|�d�}t|p:d�}|dkrXt��j|d<}|�|||�sjdS|�|||�}|dkr�dS|r�|j	nd}|r�|�
||�|�d�}|�d�dk}|s�|�r,t|dtt
���d�d	�}	|r�|	�|�n
|	�|�x"|�pdD]}
|	�|
����qW|j�|	�n|j�|�|S)
a�Captures an event.

        :param event: A ready-made event that can be directly sent to Sentry.

        :param hint: Contains metadata about the event that can be read from `before_send`, such as the original exception object or a HTTP request object.

        :returns: An event ID. May be `None` if there is no DSN set or of if the SDK decided to discard the event for other reasons. In such situations setting `debug=True` on `init()` may help.
        FN�event_idr7�attachmentsr\r])r}Zsent_at)rq)rr+rBr*�uuidZuuid4�hexrmrfZ_sessionr|rr	rr^Zadd_transactionZ	add_eventZadd_itemZto_envelope_itemrC�
capture_event)r=rcrdrer}Z	event_optrwr~Zis_transactionrD�
attachmentr7r7r8r�!s@





z_Client.capture_eventcCs"|jst�d�n|j�|�dS)Nz3Discarded session update because of missing release)r"r
rbrMZadd_session)r=rwr7r7r8�capture_sessioncsz_Client.capture_sessioncCs6|jdk	r2|j||d�|j��|j��d|_dS)z�
        Close the client and shut down the transport. Arguments have the same
        semantics as :py:meth:`Client.flush`.
        N)�timeout�callback)rB�flushrM�kill)r=r�r�r7r7r8�closels




z
_Client.closecCs:|jdk	r6|dkr|jd}|j��|jj||d�dS)a#
        Wait for the current events to be sent.

        :param timeout: Wait for at most `timeout` seconds. If no `timeout` is provided, the `shutdown_timeout` option value is used.

        :param callback: Is invoked with the number of pending events and the configured timeout.
        NZshutdown_timeout)r�r�)rBr4rMr�)r=r�r�r7r7r8r�|s



z
_Client.flushcCs|S)Nr7)r=r7r7r8�	__enter__�sz_Client.__enter__cCs|��dS)N)r�)r=�exc_type�	exc_value�tbr7r7r8�__exit__�sz_Client.__exit__)N)NN)NN)NN)�__name__ri�__qualname__�__doc__r>r?rAr<�propertyr!rfrlrmr|r�r�r�r�r�r�r7r7r7r8r:Ks&!H
'
>

r:c@seZdZdS)r;N)r�rir�r7r7r7r8r;�sr;c@seZdZdS)�ClientN)r�rir�r7r7r7r8r��sr�cCstS)N)r9r7r7r7r8�<lambda>��r�cCstS)N)r:r7r7r7r8r��r�)5r-rrnrr0Zsentry_sdk._compatrrrZsentry_sdk.utilsrrrr	r
rrr
Zsentry_sdk.serializerrZsentry_sdk.transportrZsentry_sdk.constsrrrZsentry_sdk.integrationsrrZsentry_sdk.sessionsrZsentry_sdk.enveloperZsentry_sdk._typesr�typingrrrrZsentry_sdk.scoperrrZsentry_sdk.sessionrrKr9�objectr:r)r;r�r7r7r7r8�<module>sB(
!O