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__/transport.cpython-37.pyc
B

Ta�0�@s�ddlmZddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZmZddl
mZddlmZddlmZe�rddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZm Z ee!Z"yddl#m$Z$Wn"e%k
�r@ddl&m$Z$YnXGdd�de'�Z(ddd�Z)Gdd�de(�Z*Gdd�de(�Z+dd�Z,dS)�)�print_functionN)�datetime�	timedelta)�Dsn�logger�capture_internal_exceptions�
json_dumps)�BackgroundWorker)�Envelope)�MYPY)�Any)�Callable)�Dict)�Iterable)�Optional)�Tuple)�Type)�Union)�PoolManager)�ProxyManager)�Event�EndpointType)�
getproxiesc@sHeZdZdZdZddd�Zdd�Zdd�Zdd	d
�Zdd�Z	d
d�Z
dS)�	TransportzWBaseclass for all transports.

    A transport is used to send an event to sentry.
    NcCs8||_|r.|ddk	r.|dr.t|d�|_nd|_dS)N�dsn)�optionsr�
parsed_dsn)�selfr�r�E/opt/alt/python37/lib/python3.7/site-packages/sentry_sdk/transport.py�__init__/szTransport.__init__cCs
t��dS)zm
        This gets invoked with the event dictionary when an event should
        be sent to sentry.
        N)�NotImplementedError)r�eventrrr�
capture_event9szTransport.capture_eventcCs
t��dS)a$
        Send an envelope to Sentry.

        Envelopes are a data container format that can hold any type of data
        submitted to Sentry. We use it for transactions and sessions, but
        regular "error" events should go through `capture_event` for backwards
        compat.
        N)r!)r�enveloperrr�capture_envelopeCszTransport.capture_envelopecCsdS)z=Wait `timeout` seconds for the current events to be sent out.Nr)r�timeout�callbackrrr�flushQszTransport.flushcCsdS)zForcefully kills the transport.Nr)rrrr�killZszTransport.killcCs&y|��Wntk
r YnXdS)N)r)�	Exception)rrrr�__del___szTransport.__del__)N)N)�__name__�
__module__�__qualname__�__doc__rr r#r%r(r)r+rrrrr's
	

rc
cs�|dkrt��}x�|�d�D]r}yR|���dd�\}}}|tt|�d�}x$|rZ|�d�p\dD]}||fVq^WWqttfk
r�wYqXqWdS)N�,�:�)�seconds�;)N)r�utcnow�split�stripr�int�LookupError�
ValueError)�header�now�limitZretry_after�
categories�_�categoryrrr�_parse_rate_limitsgsrAc@s�eZdZdZdd�Zdd�Zd dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd!dd�Zdd�ZdS)"�
HttpTransportzThe default HTTP transport.cCs�ddlm}t�||�|jdk	s&t�||_t|dd�|_|j�	d|�|_
i|_tj
��|_|j|j|d|d|dd	�|_dd
lm}||_dS)Nr)�VERSIONZtransport_queue_size)Z
queue_sizezsentry.python/%s�
http_proxy�https_proxy�ca_certs)rDrErF)�Hub)Zsentry_sdk.constsrCrr r�AssertionErrorrr	�_workerZto_auth�_auth�_disabled_until�urllib3�utilZRetry�_retry�
_make_pool�_pool�
sentry_sdkrG�hub_cls)rrrCrGrrrr yszHttpTransport.__init__cCsh|j�d�}|r,t�d�|j�t|��n8|jdkrdt�d�t�	�t
|j�|�pVdd�|jd<dS)Nzx-sentry-rate-limitsz%Rate-limited via x-sentry-rate-limitsi�zRate-limited via 429�<)r3)
�headers�getr�warningrK�updaterA�statusrr5rrNZget_retry_after)r�responser;rrr�_update_rate_limits�s


z!HttpTransport._update_rate_limits�storecCs�|�t|jj�t|j���d��y$|jjdt|j�|��||d�}Wn tk
rf|�	d��YnXz\|�
|�|jdkr�|�	d�n8|jdks�|jdkr�t�
d	|j|j�|�	d
�|j��Wd|��XdS)N)z
User-Agentz
X-Sentry-AuthZPOST)�bodyrTZnetworki�Z
status_429i,��z%Unexpected status code: %s (body: %s)z	status_{})rW�strrJZclientZ	to_headerrPZrequestZget_api_urlr*�on_dropped_eventrZrXr�error�data�format�close)rr\rT�
endpoint_typerYrrr�
_send_request�s0




zHttpTransport._send_requestcCsdS)Nr)r�reasonrrrr_�szHttpTransport.on_dropped_eventcs�fdd�}||�p|d�S)Ncs �j�|�}|dk	o|t��kS)N)rKrUrr5)�bucket�ts)rrr�	_disabled�sz0HttpTransport._check_disabled.<locals>._disabledr)rr@rir)rr�_check_disabled�szHttpTransport._check_disabledc	Cs�|�d�r|�d�dSt��}tj|dd��}|�t|��WdQRX|jdk	sVt	�t
�d|�d�phd|�d�ptd|�d	�p�d|jj
|jjf�|j|��d
dd�d
�dS)Nr`Zself_rate_limits�w)�fileobj�modez>Sending event, type:%s level:%s event_id:%s project:%s host:%s�type�null�levelZevent_idzapplication/json�gzip)zContent-TypezContent-Encoding)rT)rjr_�io�BytesIOrq�GzipFile�writerrrHr�debugrU�
project_id�hostre�getvalue)rr"r\�frrr�_send_event�s$

zHttpTransport._send_eventc	s��fdd�|jD�|jdd�<|js(dSt��}tj|dd��}|�|�WdQRX�jdk	sbt�t�	d|j
�jj�jj��j
|��ddd�d	d
�dS)Ncsg|]}��|j�s|�qSr)rjZ
data_category)�.0�x)rrr�
<listcomp>sz0HttpTransport._send_envelope.<locals>.<listcomp>rk)rlrmz(Sending envelope [%s] project:%s host:%szapplication/x-sentry-enveloperq)zContent-TypezContent-Encodingr$)rTrd)�itemsrrrsrqrtZserialize_intorrHrrv�descriptionrwrxrery)rr$r\rzr)rr�_send_envelope�s$
zHttpTransport._send_envelopecCsdd|pt��d�S)Nr2Z
CERT_REQUIRED)Z	num_poolsZ	cert_reqsrF)�certifi�where)rrFrrr�_get_pool_optionsszHttpTransport._get_pool_optionscCsPt��d�}|sdSx6|�d�D](}|��}|j�|�sD|j�|�r dSq WdS)N�noFr0T)rrUr6r7rx�endswith�netloc)rr�no_proxyrxrrr�_in_no_proxy$szHttpTransport._in_no_proxycCs�d}|�|�}|jdkr6|dkr6|p4|o4t��d�}|sX|dkrX|pV|oVt��d�}|�|�}|rttj|f|�Stjf|�SdS)N�https��http)r��schemerrUr�rLrr)rrrDrErF�proxyr��optsrrrrO/s

zHttpTransport._make_poolcs2�jj����fdd�}�j�|�s.��d�dS)Nc
s0��"t������WdQRXWdQRXdS)N)rr{r)r"�hubrrr�send_event_wrapperOsz7HttpTransport.capture_event.<locals>.send_event_wrapper�
full_queue)rR�currentrI�submitr_)rr"r�r)r"r�rrr#IszHttpTransport.capture_eventcs2�jj����fdd�}�j�|�s.��d�dS)Nc
s0��"t������WdQRXWdQRXdS)N)rr�r)r$r�rrr�send_envelope_wrapper^sz=HttpTransport.capture_envelope.<locals>.send_envelope_wrapperr�)rRr�rIr�r_)rr$r�r)r$r�rrr%XszHttpTransport.capture_envelopeNcCs$t�d�|dkr |j�||�dS)NzFlushing HTTP transportr)rrvrIr()rr&r'rrrr(gs
zHttpTransport.flushcCst�d�|j��dS)NzKilling HTTP transport)rrvrIr))rrrrr)qs
zHttpTransport.kill)r[)N)r,r-r.r/r rZrer_rjr{r�r�r�rOr#r%r(r)rrrrrBvs
'	!
rBc@seZdZdd�Zdd�ZdS)�_FunctionTransportcCst�|�||_dS)N)rr �_func)r�funcrrrr xs
z_FunctionTransport.__init__cCs|�|�dS)N)r�)rr"rrrr#s
z _FunctionTransport.capture_eventN)r,r-r.r r#rrrrr�wsr�cCsb|d}|dkrt}n8t|t�r$|St|t�r>t|t�r>|}nt|�rNt|�S|dr^||�SdS)NZ	transportr)rB�
isinstancerrn�
issubclass�callabler�)rZ
ref_transportZ
transport_clsrrr�make_transport�s
r�)N)-�
__future__rrrrLr�rqrrZsentry_sdk.utilsrrrrZsentry_sdk.workerr	Zsentry_sdk.enveloper
Zsentry_sdk._typesr�typingrr
rrrrrrZurllib3.poolmanagerrrrrr^ZDataCategoryZurllib.requestr�ImportError�urllib�objectrrArBr�r�rrrr�<module>sB@