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



\!@sddlZddlZddlZddlmZddlmZmZddlmZm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZmZddlmZddlmZed	Zd
dZGdd
d
eZdS)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_debugcOsN|rFt|dts)|ddkrF|d}|dd}nd}tt}t||}|dk	r|jddkr||d<xC|jD]5\}}||krtd|f|||<qW|ddkrtjjd|d<|ddkr$tjjd|d<|ddkrJtjjd	|d<|S)
NrdsnzUnknown option %rZ
SENTRY_DSNreleaseZSENTRY_RELEASEenvironmentZSENTRY_ENVIRONMENT)	
isinstancerdictrgetitems	TypeErrorosenviron)argskwargsrrvoptionskeyvaluer#
/client.pyget_options!s&)
!
r%c@seZdZdZddZeddZddZdd	Zd
ddZ	d
d
d
dZ
d
d
ddZd
d
ddZ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.
    cOstjd}zt|||_}tj|dt||_d}|d|krstdj|t	|d	d
|d|_
Wdtj|XdS)
NFdebugalwaysneversmallmediumrequest_bodiesz3Invalid value for request_bodies. Must be one of {}integrationsZ
with_defaultsZdefault_integrations)r(r)r*r+)_client_init_debugrr%r setr
	transport
ValueErrorformatrr-)selfrrZ	old_debugr r,r#r#r$__init__FszClient.__init__cCs|jdS)z%Returns the configured DSN as string.r)r )r3r#r#r$r\sz
Client.dsncCs-|jddkr%tj|d<|dk	rS|j||}|dkrSdS|jdrd|krd|krd|krt1dt|jdddd	d
ig|d<WdQRXxSdD]K}|j|dkr|j|dk	rt|j|j||<qW|jddkr[t	t
}t|jj
|d<||d<|jddkrzd|d<t||jd|jd}|dk	rt|}t|t|}|jd}|dk	r)d}t|||}WdQRX|dkr#tjd||}|S)NZ	timestampZattach_stacktrace	exceptionZ
stacktracethreadsZwith_localsZcrashedFcurrentTrrserver_namedistZsdkr-platformpythonZin_app_excludeZin_app_includebefore_sendzbefore send dropped event (%s))rrr8r9)rrZutcnowZapply_to_eventr r
rrstriprrsortedr-keysrrrrrinfo)r3eventhintscoper!Zsdk_infor<Z	new_eventr#r#r$_prepare_eventasL


(!




zClient._prepare_eventcCs|jd}|dkrdSt|d}d|dj|f}xZ|jdD]K}t|tr||ks||krdSqTt|d|rTdSqTWdS)Nexc_infoFrz%s.%s
ignore_errorsT)rr	
__module__r rr
issubclass)r3rArBrEZ	type_nameZ	full_nameZerrclsr#r#r$_is_ignored_errorszClient._is_ignored_errorNcCsd|dk	r|jrdS|jddkrJtj|jdkrJdS|j||r`dSdS)NFZsample_rateg?T)_should_capturer randomrI)r3rArBrCr#r#r$rJszClient._should_capturecCs|jdkrdS|dkr%i}|jd}|dkrWtjj|d<}|j|||spdS|j|||}|dkrdS|jj||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)r0ruuidZuuid4hexrJrD
capture_event)r3rArBrCrr#r#r$rNszClient.capture_eventcCs?|jdk	r;|jd|d||jjd|_dS)z|
        Close the client and shut down the transport. Arguments have the same
        semantics as `self.flush()`.
        Ntimeoutcallback)r0flushkill)r3rOrPr#r#r$closes
zClient.closecCsE|jdk	rA|dkr(|jd}|jjd|d|dS)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_timeoutrOrP)r0r rQ)r3rOrPr#r#r$rQs	
zClient.flushcCs|S)Nr#)r3r#r#r$	__enter__szClient.__enter__cCs|jdS)N)rS)r3exc_type	exc_valuetbr#r#r$__exit__szClient.__exit__)__name__rG__qualname____doc__r4propertyrrDrIrJrNrSrQrTrXr#r#r#r$r&?s?
r&)rrLrKrZsentry_sdk._compatrrZsentry_sdk.utilsrrrrr	r
rrZsentry_sdk.transportr
Zsentry_sdk.constsrrZsentry_sdk.integrationsrrr.r%objectr&r#r#r#r$<module>s:


Back to Directory File Manager