<!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 mZ d dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZmZ G dd	 d	e	ZG d
d deZdd ZdS )    )absolute_import)Hub)capture_internal_exceptionsevent_from_exceptiontransaction_from_function)Integration)SentryWsgiMiddleware)RequestExtractor)BottleRouterequestHTTPResponsec                   @   s*   e Zd ZdZdZdddZedd ZdS )	BottleIntegrationbottleNendpointc                 C   s&   d}||krt d||f || _d S )N)r   urlz7Invalid value for transaction_style: %s (must be in %s))
ValueErrortransaction_style)selfr   ZTRANSACTION_STYLE_VALUES r   O/opt/alt/python38/lib/python3.8/site-packages/sentry_sdk/integrations/bottle.py__init__"   s    zBottleIntegration.__init__c                     sL   t j  fdd} | t _t jfdd}|t _tjfdd}|t_d S )Nc                    s<   t j}|t}|d kr$ ||S t fdd||S )Nc                     s    f| |S Nr   )akw)old_appr   r   r   <lambda>;       zOBottleIntegration.setup_once.<locals>.sentry_patched_wsgi_app.<locals>.<lambda>)r   currentget_integrationr   r   )r   environZstart_responsehubintegration)r   r   r   sentry_patched_wsgi_app3   s    
 z=BottleIntegration.setup_once.<locals>.sentry_patched_wsgi_appc              
      sx   t j}|t}|d kr" | |S | }|@ | }| }d|_|t|t	| W 5 Q R X  | |}W 5 Q R X |S )Nr   )
r   r   r   r   Z
push_scopeZconfigure_scope_nameZadd_event_processor_make_request_event_processorbottle_request)r   r    r!   r"   Zscope_managerappZscoperes)
old_handler   r   _patched_handleD   s    



z5BottleIntegration.setup_once.<locals>._patched_handlec                    s>   t j  t}| f|||d kr,S  fdd}|S )Nc               
      sb    fdd}z| |}W nB t k
r0    Y n. tk
r\ } z|| |W 5 d }~X Y nX |S )Nc                    s.   t |  jjdddd\}} j||d d S )Nr   F)typeZhandled)Zclient_optionsZ	mechanism)hint)r   ZclientoptionsZcapture_event)	exceptioneventr-   )r!   r   r   capture_exceptionf   s    
zpBottleIntegration.setup_once.<locals>.patched_make_callback.<locals>.wrapped_callback.<locals>.capture_exception)r   	Exception)argskwargsr1   r)   r/   r!   Zprepared_callbackr   r   wrapped_callbacke   s    zUBottleIntegration.setup_once.<locals>.patched_make_callback.<locals>.wrapped_callback)r   r   r   r   )r   r3   r4   r"   r6   )old_make_callbackr5   r   patched_make_callback^   s    
z;BottleIntegration.setup_once.<locals>.patched_make_callback)r
   __call__Z_handler   Z_make_callback)r$   r+   r8   r   )r   r*   r7   r   
setup_once,   s    zBottleIntegration.setup_once)r   )__name__
__module____qualname__Z
identifierr   r   staticmethodr:   r   r   r   r   r      s
   

r   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )BottleRequestExtractorc                 C   s   | j jS r   )r   r    r#   r   r   r   env~   s    zBottleRequestExtractor.envc                 C   s   | j jS r   )r   cookiesr#   r   r   r   rA      s    zBottleRequestExtractor.cookiesc                 C   s   | j j S r   )r   Zbodyreadr#   r   r   r   raw_data   s    zBottleRequestExtractor.raw_datac                 C   s   |   rd S | jj S r   )is_jsonr   Zformsdecoder#   r   r   r   form   s    zBottleRequestExtractor.formc                 C   s   |   rd S | jjS r   )rD   r   filesr#   r   r   r   rG      s    zBottleRequestExtractor.filesc                 C   s   |j S r   )Zcontent_length)r   filer   r   r   size_of_file   s    z#BottleRequestExtractor.size_of_fileN)	r;   r<   r=   r@   rA   rC   rF   rG   rI   r   r   r   r   r?   }   s   r?   c                    s    fdd}|S )Nc              	      sx   z> j dkr&jjptjj| d< n j dkr<jj| d< W n tk
rR   Y nX t  t	|  W 5 Q R X | S )Nr   Ztransactionr   )
r   Zroutenamer   callbackZruler2   r   r?   Zextract_into_event)r0   r-   r"   r   r   r   inner   s    



z,_make_request_event_processor.<locals>.innerr   )r(   r   r"   rM   r   rL   r   r&      s    r&   N)Z
__future__r   Zsentry_sdk.hubr   Zsentry_sdk.utilsr   r   r   Zsentry_sdk.integrationsr   Zsentry_sdk.integrations.wsgir   Z$sentry_sdk.integrations._wsgi_commonr	   Z_ScopedResponseZAnyZDictCallableZOptionalZ
FileUploadZ	FormsDictZLocalRequestr   r
   r   r   r'   r   r   r?   r&   r   r   r   r   <module>   s   
`