<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    \!                     @   s   d dl Z d dlZd dlZd dlmZ d dlmZmZ d dlmZm	Z	m
Z
mZmZmZmZmZ d dlmZ d dlmZmZ d dlmZ d dlmZ ed	Zd
d ZG dd deZ dS )    N)datetime)string_types	text_type)strip_event_mutflatten_metadataconvert_typeshandle_in_appget_type_namecapture_internal_exceptionscurrent_stacktracelogger)make_transport)DEFAULT_OPTIONSSDK_INFO)setup_integrations)
ContextVarZclient_init_debugc                  O   s   | r4t | d ts| d d kr4| d }| dd  } nd }tt}t| |}|d k	rh|dd krh||d< | D ]&\}}||krtd|f |||< qp|d d krtjd|d< |d d krtjd|d< |d d krtjd	|d< |S )
Nr      dsnzUnknown option %rZ
SENTRY_DSNreleaseZSENTRY_RELEASEenvironmentZSENTRY_ENVIRONMENT)	
isinstancer   dictr   getitems	TypeErrorosenviron)argskwargsr   rvoptionskeyvalue r#   B/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/client.pyget_options!   s&    

r%   c                   @   sl   e Zd ZdZdd Zedd Zdd Zdd	 ZdddZ	dddZ
dddZdddZdd Zdd Zd
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              	   O   s|   t d}z`t|| | _}t |d  t|| _d}|d |krRtd|t	|d |d d| _
W 5 t | X d S )	NFdebug)alwaysneverZsmallZmediumrequest_bodiesz3Invalid value for request_bodies. Must be one of {}integrationsZdefault_integrations)Zwith_defaults)_client_init_debugr   setr%   r    r   	transport
ValueErrorformatr   r+   )selfr   r   Z	old_debugr    r*   r#   r#   r$   __init__F   s"    

 zClient.__init__c                 C   s
   | j d S )z%Returns the configured DSN as string.r   )r    r1   r#   r#   r$   r   \   s    z
Client.dsnc              	   C   s  | dd krt |d< |d k	r:|||}|d kr:d S | jd rd|krd|krd|krt " t| jd ddd	g|d< W 5 Q R X d
D ]6}| |d kr| j| d k	rt| j|  ||< q| dd krt	t
}t| j |d< ||d< | dd krd|d< t|| jd | jd }|d k	rHt|}t| t|}| jd }|d k	rd }t  |||}W 5 Q R X |d krtd| |}|S )NZ	timestampZattach_stacktraceZ	exception
stacktracethreadsZwith_localsFT)r4   Zcrashedcurrent)r   r   Zserver_namedistZsdkr+   platformpythonZin_app_excludeZin_app_includebefore_sendzbefore send dropped event (%s))r   r   ZutcnowZapply_to_eventr    r
   r   r   stripr   r   sortedr+   keysr   r   r   r   r   info)r1   eventhintscoper!   Zsdk_infor:   Z	new_eventr#   r#   r$   _prepare_eventa   s^      



zClient._prepare_eventc                 C   s~   | d}|d krdS t|d }d|d j|f }| jd D ]:}t|trd||ks\||krx dS q>t|d |r> dS q>dS )Nexc_infoFr   z%s.%signore_errorsT)r   r	   
__module__r    r   r   
issubclass)r1   r?   r@   rC   Z	type_nameZ	full_nameZerrclsr#   r#   r$   _is_ignored_error   s    

zClient._is_ignored_errorNc                 C   sJ   |d k	r|j sdS | jd dk r6t | jd kr6dS | ||rFdS dS )NFZsample_rateg      ?T)_should_capturer    randomrG   )r1   r?   r@   rA   r#   r#   r$   rH      s    zClient._should_capturec                 C   sz   | j dkrdS |dkri }|d}|dkr>t j |d< }| |||sPdS | |||}|dkrjdS | j | |S )a  Captures 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.
        NZevent_id)r.   r   uuidZuuid4hexrH   rB   capture_event)r1   r?   r@   rA   r   r#   r#   r$   rL      s    

zClient.capture_eventc                 C   s,   | j dk	r(| j||d | j   d| _ dS )z|
        Close the client and shut down the transport. Arguments have the same
        semantics as `self.flush()`.
        Ntimeoutcallback)r.   flushkillr1   rN   rO   r#   r#   r$   close   s    

zClient.closec                 C   s0   | j dk	r,|dkr| jd }| j j||d dS )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.
        NZshutdown_timeoutrM   )r.   r    rP   rR   r#   r#   r$   rP      s    	

zClient.flushc                 C   s   | S Nr#   r3   r#   r#   r$   	__enter__   s    zClient.__enter__c                 C   s   |    d S rT   )rS   )r1   exc_type	exc_valuetbr#   r#   r$   __exit__   s    zClient.__exit__)N)NN)NN)NN)__name__rE   __qualname____doc__r2   propertyr   rB   rG   rH   rL   rS   rP   rU   rY   r#   r#   r#   r$   r&   ?   s   
? 




r&   )!r   rJ   rI   r   Zsentry_sdk._compatr   r   Zsentry_sdk.utilsr   r   r   r   r	   r
   r   r   Zsentry_sdk.transportr   Zsentry_sdk.constsr   r   Zsentry_sdk.integrationsr   r   ZClientOptionsZScopeZAnyZDictZOptionalr,   r%   objectr&   r#   r#   r#   r$   <module>   s   (

