Viewing File: /opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/__pycache__/transport.cpython-38.pyc

U

\'@sddlmZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
mZddlmZzddlmZWn ek
rddlmZYnXGdd	d	eZGd
ddeZ Gdd
d
eZ!ddZ"dS))print_functionN)datetime	timedelta)VERSION)Dsnloggercapture_internal_exceptions)BackgroundWorker)
getproxiesc@s@eZdZdZdZd
ddZddZdddZd	d
ZddZ	dS)	TransportzWBaseclass for all transports.

    A transport is used to send an event to sentry.
    NcCs,||_|r"|dr"t|d|_nd|_dS)Ndsn)optionsr
parsed_dsn)selfr
r
/transport.py__init__(szTransport.__init__cCs
tdS)zdThis gets invoked with the event dictionary when an event should
        be sent to sentry.
        N)NotImplementedErrorreventrrr
capture_event0szTransport.capture_eventcCsdS)z=Wait `timeout` seconds for the current events to be sent out.NrrZtimeoutcallbackrrrflush6szTransport.flushcCsdS)zForcefully kills the transport.Nrrrrrkill:szTransport.killcCs&z|Wntk
r YnXdSN)r	Exceptionrrrr__del__?szTransport.__del__)N)N)
__name__
__module____qualname____doc__rrrrrrrrrrr s

rc@sJeZdZdZddZddZddZdd	Zd
dZdd
dZ	ddZ
dS)
HttpTransportzThe default HTTP transport.cCsvt||t|_|jdt|_d|_t	j
|_||_
|j|j|d|d|dd|_ddlm}||_dS)Nzsentry.python/%s
http_proxyhttps_proxyca_certs)r$r%r&r)Hub)rrr	_workerrZto_authr_auth_disabled_untilurllib3utilZRetry_retryr

_make_pool_poolZ
sentry_sdkr'hub_cls)rr
r'rrrrJszHttpTransport.__init__c	Cs2|jdk	r"t|jkrdSd|_t}tj|dd }|tj	|dd
dW5QRXtd|
dppd|d	|jj|jjf|jjd
t|jj|t|jddd
d}z`|jdkrtt|j|pdd|_W2dS|jdks|jdkrtd|j|jW5|Xd|_dS)Nw)ZfileobjmodeF)Z	allow_nanzutf-8z&Sending %s event [%s] to %s project:%slevelerrorZevent_idZPOSTzapplication/jsongzip)z
X-Sentry-AuthzContent-TypezContent-Encoding)bodyZheadersi<)Zsecondsi,z%Unexpected status code: %s (body: %s))r*rZutcnowioBytesIOr5ZGzipFilewritejsondumpsencoderdebuggetrZhostZ
project_idr/Zrequeststrr)Z
store_api_urlgetvalueZ	to_headercloseZstatusrr-Zget_retry_afterr4data)rrr6fZresponserrr_send_event^sN
$	



zHttpTransport._send_eventcCsdd|ptdS)NZ
CERT_REQUIRED)Z	num_poolsZ	cert_reqsr&)certifiwhere)rr&rrr_get_pool_optionss
zHttpTransport._get_pool_optionscCsP|jdkr|p|}|s$t|j}||}|r@tj|f|Stjf|SdS)NZhttps)Zschemer
r@rJr+ProxyManagerPoolManager)rrr$r%r&proxyZoptsrrrr.s	
zHttpTransport._make_poolcs(jjfdd}j|dS)Nc
s0"tW5QRXW5QRXdSr)rrFrrZhubrrrsend_event_wrappersz7HttpTransport.capture_event.<locals>.send_event_wrapper)r0Zcurrentr(Zsubmit)rrrOrrNrrszHttpTransport.capture_eventNcCs$td|dkr |j||dS)NzFlushing HTTP transportr)rr?r(rrrrrrs
zHttpTransport.flushcCstd|jdS)NzKilling HTTP transport)rr?r(rrrrrrs
zHttpTransport.kill)N)rr r!r"rrFrJr.rrrrrrrr#Gs1
r#c@seZdZddZddZdS)_FunctionTransportcCst|||_dSr)rr_func)rfuncrrrrs
z_FunctionTransport.__init__cCs||dSr)rQrrrrrs
z _FunctionTransport.capture_eventN)rr r!rrrrrrrPsrPcCsj|d}|dkrt}n@zt|tWn,tk
rPt|rHt|YS|YSX|}|drf||SdS)NZ	transportr)r#
issubclasstype	TypeErrorcallablerP)r
Z
ref_transportZ
transport_clsrrrmake_transports
rW)#Z
__future__rr<r9r+rHr5rrZsentry_sdk.constsrZsentry_sdk.utilsrrrZsentry_sdk.workerr	Z
ClientOptionsZTypeZAnyZOptionalZDictZUnionCallablerLrKZurllib.requestr
ImportErrorZurllibobjectrr#rPrWrrrr<module>s"
'|
Back to Directory File Manager