Viewing File: /opt/alt/python35/lib/python3.5/site-packages/sentry_sdk/__pycache__/transport.cpython-35.opt-1.pyc



\'@s)ddlmZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
mZddlmZyddlmZWn"ek
rddlmZYnXGdd	d	eZGd
ddeZGdd
d
eZddZdS))print_functionN)datetime	timedelta)VERSION)Dsnloggercapture_internal_exceptions)BackgroundWorker)
getproxiesc@s^eZdZdZdZdddZddZdddZd	d
ZddZ	dS)
	TransportzWBaseclass for all transports.

    A transport is used to send an event to sentry.
    NcCs<||_|r/|dr/t|d|_n	d|_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)NotImplementedError)reventrrr
capture_event0szTransport.capture_eventcCsdS)z=Wait `timeout` seconds for the current events to be sent out.Nr)rtimeoutcallbackrrrflush6szTransport.flushcCsdS)zForcefully kills the transport.Nr)rrrrkill:szTransport.killcCs'y|jWntk
r"YnXdS)N)r	Exception)rrrr__del__?s
zTransport.__del__)
__name__
__module____qualname____doc__rrrrrrrrrrr src@smeZdZdZddZddZddZdd	Zd
dZdd
dZ	ddZ
dS)
HttpTransportzThe default HTTP transport.c	Cstj||t|_|jjdt|_d|_t	j
j|_||_
|j|jd|dd|dd|d|_ddlm}||_dS)Nzsentry.python/%s
http_proxyhttps_proxyca_certsr)Hub)rrr	_workerrZto_authr_auth_disabled_untilurllib3utilZRetry_retryr

_make_pool_poolZ
sentry_sdkr$hub_cls)rr
r$rrrrJs			

zHttpTransport.__init__cCs|jdk	r1tj|jkr(dSd|_tj}tjd|dd,}|jtj	|ddj
dWdQRXtjd|j
dpd	|d
|jj|jjf|jjdt|jjd|jd
dt|jjddddi}z||jdkrXtjtd|jj|pJd|_dS|jdksv|jdkrtjd|j|jWd|jXd|_dS)NfileobjmodewZ	allow_nanFzutf-8z&Sending %s event [%s] to %s project:%slevelerrorZevent_idZPOSTbodyZheadersz
X-Sentry-AuthzContent-Typezapplication/jsonzContent-EncodinggzipiZseconds<i,z%Unexpected status code: %s (body: %s))r'rZutcnowioBytesIOr4ZGzipFilewritejsondumpsencoderdebuggetrhostZ
project_idr,Zrequeststrr&Z
store_api_urlgetvalueZ	to_headerstatusrr*Zget_retry_afterr2dataclose)rrr3fresponserrr_send_event^s@	,		zHttpTransport._send_eventcCs"ddddd|ptjiS)NZ	num_poolsZ	cert_reqsZ
CERT_REQUIREDr#)certifiZwhere)rr#rrr_get_pool_optionsszHttpTransport._get_pool_optionscCsl|jdkr|p|}|s6tj|j}|j|}|r[tj||Stj|SdS)NZhttps)schemer
r>rJr(ZProxyManagerZPoolManager)rrr!r"r#proxyZoptsrrrr+s	zHttpTransport._make_poolcs8jjfdd}jj|dS)Ncs0#tjWdQRXWdQRXdS)N)rrGr)rhubrrrsend_event_wrappers
z7HttpTransport.capture_event.<locals>.send_event_wrapper)r-currentr%submit)rrrNr)rrMrrrszHttpTransport.capture_eventNcCs0tjd|dkr,|jj||dS)NzFlushing HTTP transportr)rr=r%r)rrrrrrrs
zHttpTransport.flushcCstjd|jjdS)NzKilling HTTP transport)rr=r%r)rrrrrs
zHttpTransport.kill)rrrrrrGrJr+rrrrrrrr Gs1r c@s(eZdZddZddZdS)_FunctionTransportcCstj|||_dS)N)rr_func)rfuncrrrrs
z_FunctionTransport.__init__cCs|j|dS)N)rR)rrrrrrs
z _FunctionTransport.capture_eventN)rrrrrrrrrrQsrQcCs}|d}|dkrt}nFyt|tWn,tk
r^t|rVt|S|SYnX|}|dry||SdS)NZ	transportr)r 
issubclasstype	TypeErrorcallablerQ)r
Z
ref_transportZ
transport_clsrrrmake_transports
	

	

rX)Z
__future__rr:r7r(rIr4rrZsentry_sdk.constsrZsentry_sdk.utilsrrrZsentry_sdk.workerr	Zurllib.requestr
ImportErrorurllibobjectrr rQrXrrrr<module>s"

'|
Back to Directory File Manager