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

U

\!@sddlZddlZddlZddlmZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZed	Zd
dZGdd
d
eZ dS)N)datetime)string_types	text_type)strip_event_mutflatten_metadata
convert_types
handle_in_app
get_type_namecapture_internal_exceptionscurrent_stacktracelogger)make_transport)DEFAULT_OPTIONSSDK_INFO)setup_integrations)
ContextVarZclient_init_debugcOs|r4t|dts|ddkr4|d}|dd}nd}tt}t||}|dk	rh|ddkrh||d<|D]&\}}||krtd|f|||<qp|ddkrtjd|d<|ddkrtjd|d<|ddkrtjd	|d<|S)
NrdsnzUnknown option %rZ
SENTRY_DSNreleaseZSENTRY_RELEASEenvironmentZSENTRY_ENVIRONMENT)	
isinstancerdictrgetitems	TypeErrorosenviron)argskwargsrrvoptionskeyvaluer#
/client.pyget_options!s&

r%c@sleZdZdZddZeddZddZdd	ZdddZ	dd
dZ
dddZdddZddZ
ddZd
S)ClientzThe 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.
    c	Os|td}z`t|||_}t|dt||_d}|d|krRtd|t	|d|dd|_
W5t|XdS)	NFdebug)alwaysneverZsmallZmediumrequest_bodiesz3Invalid value for request_bodies. Must be one of {}integrationsZdefault_integrations)Z
with_defaults)_client_init_debugrsetr%r r
	transport
ValueErrorformatrr+)selfrrZ	old_debugr r*r#r#r$__init__Fs"

zClient.__init__cCs
|jdS)z%Returns the configured DSN as string.r)r r1r#r#r$r\sz
Client.dsnc	Cs|ddkrt|d<|dk	r:|||}|dkr:dS|jdrd|krd|krd|krt"t|jdddd	g|d<W5QRXd
D]6}||dkr|j|dk	rt|j|||<q|ddkrt	t
}t|j
|d<||d<|d
dkrd|d
<t||jd|jd}|dk	rHt|}t|t|}|jd}|dk	rd}t|||}W5QRX|dkrtd||}|S)NZ	timestampZattach_stacktraceZ	exception
stacktraceZthreadsZwith_localsFT)r4ZcrashedZcurrent)rrZserver_nameZdistZsdkr+platformpythonZin_app_excludeZin_app_includebefore_sendzbefore send dropped event (%s))rrZutcnowZapply_to_eventr r
rrstriprrsortedr+keysrrrrrinfo)r1eventhintscoper!Zsdk_infor7Z	new_eventr#r#r$_prepare_eventas^



zClient._prepare_eventcCs~|d}|dkrdSt|d}d|dj|f}|jdD]:}t|trd||ks\||krxdSq>t|d|r>dSq>dS)Nexc_infoFrz%s.%s
ignore_errorsT)rr	
__module__r rr
issubclass)r1r<r=r@Z	type_nameZ	full_nameZerrclsr#r#r$_is_ignored_errors

zClient._is_ignored_errorNcCsJ|dk	r|jsdS|jddkr6t|jdkr6dS|||rFdSdS)NFZsample_rateg?T)_should_capturer randomrD)r1r<r=r>r#r#r$rEszClient._should_capturecCsz|jdkrdS|dkri}|d}|dkr>tj|d<}||||sPdS||||}|dkrjdS|j||S)aCaptures an event.

        This takes the ready made event and an optoinal hint and scope.  The
        hint is internally used to further customize the representation of the
        error.  When provided it's a dictionary of optional information such
        as exception info.

        If the transport is not set nothing happens, otherwise the return
        value of this function will be the ID of the captured event.
        NZevent_id)r.ruuidZuuid4hexrEr?
capture_event)r1r<r=r>rr#r#r$rIs

zClient.capture_eventcCs,|jdk	r(|j||d|jd|_dS)z|
        Close the client and shut down the transport. Arguments have the same
        semantics as `self.flush()`.
        Ntimeoutcallback)r.flushkillr1rKrLr#r#r$closes

zClient.closecCs0|jdk	r,|dkr|jd}|jj||ddS)a{
        Wait `timeout` seconds for the current events to be sent. If no
        `timeout` is provided, the `shutdown_timeout` option value is used.

        The `callback` is invoked with two arguments: the number of pending
        events and the configured timeout.  For instance the default atexit
        integration will use this to render out a message on stderr.
        NZshutdown_timeoutrJ)r.r rMrOr#r#r$rMs	

zClient.flushcCs|SNr#r3r#r#r$	__enter__szClient.__enter__cCs|dSrQ)rP)r1exc_type	exc_valuetbr#r#r$__exit__szClient.__exit__)N)NN)NN)NN)__name__rB__qualname____doc__r2propertyrr?rDrErIrPrMrRrVr#r#r#r$r&?s
?




r&)!rrGrFrZsentry_sdk._compatrrZsentry_sdk.utilsrrrrr	r
rrZsentry_sdk.transportr
Zsentry_sdk.constsrrZsentry_sdk.integrationsrrZ
ClientOptionsZScopeZAnyZDictZOptionalr,r%objectr&r#r#r#r$<module>s(


Back to Directory File Manager