U
    /e
                     @   s@   d Z ddlZejeZejejejeZdd ZdS )z?Script injected into the debuggee process during attach-to-PID.    Nc                    s  d }zdd l  d jkrz~ fdd} fdd} fdd}tjtd	d
dd}tj|sdt jd| dd l	}|j
|||d  j| W n   dd l}|   Y nX  jdt z,dd l}dd l}ddlm}	m} dd l}
W 5  jd tkst jd= X |
 }|d k	r0|jdd | d d k	rL|| d  |d|	|  | d dkr||| d  n2| d dkr|j| d | d d ntt| W n2   dd l}|  |d krւ n|  Y nX |d d S )Nr   	threadingc                    s   t |  jd d S N)fileprintstderrmsgsys F/tmp/pip-unpacked-wheel-dg3irmqq/debugpy/server/attach_pid_injected.pyon_warn   s    zattach.<locals>.on_warnc                    s   t |  jd d S r   r   r   r
   r   r   on_exception   s    zattach.<locals>.on_exceptionc                    s   t |  jd d S r   r   r   r
   r   r   on_critical   s    zattach.<locals>.on_criticaldebugpyZ	_vendoredpydevdZpydevd_attach_to_process)r   r   r   )jsonlogF)waitlog_toz!Configuring injected debugpy: {0}modelistenaddressconnectZadapter_access_token)Zaccess_tokenzdebugpy injected successfully)r   modulesospathjoin_debugpy_direxistsAssertionErrorinsertattach_scriptZfix_main_thread_idremove	traceback	print_excr   Zdebugpy.serverZdebugpy.commonr   r   r   Zget_global_debuggerZ#dispose_and_kill_all_pydevd_threadsr   inforeprr   r   Zreraise_exception)setupr   r   r   r   Zpydevd_attach_to_process_pathr#   r%   r   r   r   Zpy_dbr   r
   r   attach   sr    
  

 
r*   )__doc__r   r   abspath__file__dirnamer   r*   r   r   r   r   <module>   s   