o
    h	                     @   s|   d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlm	Z	 e	r0d dl
mZ d dlmZmZ G dd deZd	d
 ZdS )    N)capture_internal_exceptionsevent_from_exception)Integration)TYPE_CHECKING)Callable)NoReturnUnionc                   @   s:   e Zd ZdZdZddddZedd Zed	d
 ZdS )SysExitIntegrationaM  Captures sys.exit calls and sends them as events to Sentry.

    By default, SystemExit exceptions are not captured by the SDK. Enabling this integration will capture SystemExit
    exceptions generated by sys.exit calls and send them to Sentry.

    This integration, in its default configuration, only captures the sys.exit call if the exit code is a non-zero and
    non-None value (unsuccessful exits). Pass `capture_successful_exits=True` to capture successful exits as well.
    Note that the integration does not capture SystemExit exceptions raised outside a call to sys.exit.
    sys_exitF)capture_successful_exitsc                C   s
   || _ d S N)_capture_successful_exits)selfr    r   b/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/sentry_sdk/integrations/sys_exit.py__init__   s   
zSysExitIntegration.__init__c                   C   s   t   d S r   )r	   _patch_sys_exitr   r   r   r   
setup_once   s   zSysExitIntegration.setup_oncec                     s(   t j t d fdd	} | t _d S )Nr   c                    s   t  t}|d u r |  z |  W d S  tyK } z)t  |js)| dvr5t| W d    |W d    |1 s@w   Y  |d }~ww )N)r   N)
sentry_sdk
get_clientget_integrationr	   
SystemExitr   r   _capture_exception)_SysExitIntegration__statusintegrationeold_exitr   r   sentry_patched_exit)   s$   


z?SysExitIntegration._patch_sys_exit.<locals>.sentry_patched_exit)r   )sysexit	functoolswraps)r   r   r   r   r   $   s   
z"SysExitIntegration._patch_sys_exitN)	__name__
__module____qualname____doc__
identifierr   staticmethodr   r   r   r   r   r   r	      s    

r	   c                 C   s2   t | t jtjddd\}}tj||d d S )NF)typehandled)client_options	mechanism)hint)r   r   r   optionsr	   r'   capture_event)exceventr-   r   r   r   r   ?   s   

r   )r!   r   r   sentry_sdk.utilsr   r   sentry_sdk.integrationsr   sentry_sdk._typesr   collections.abcr   typingr   r   r	   r   r   r   r   r   <module>   s    1