Format: application/x-python-code
⬇ Download File (2.9 KB)
   1  o
   2  
   3  ��h�@sLddlZddlZddlZddlmZddlmZGdd�de�Zdd�Z	dS)�N)�launcher)�logc@s8eZdZdZiZ	dd�Zdd�Zdd�Zdd	d
   4  �ZdS)
   5  �
   6  CaptureOutputz�Captures output from the specified file descriptor, and tees it into another
   7      file descriptor while generating DAP "output" events for it.
   8      c	Cs�||jvsJ�||j|<t�d||�||_||_||_t�d�dd�|_|dur-d|_	n9|j
   9  |_	|j}|dus<|dkr>d}zt�|�|_
  10  Wnty^tjd||dd�t�d�|_
  11  Ynwt�d	||�tj|j|d
  12  �|_|j��dS)NzCapturing {0} of {1}.zutf-8�surrogateescape)�errors�cp65001z6Unsupported {0} encoding {1!r}; falling back to UTF-8.�warning)�levelzUsing encoding {0!r} for {1})�target�name)�	instancesr�info�category�_whose�_fd�codecs�getincrementaldecoder�_decoder�_stream�buffer�encoding�
  13  getencoder�_encode�	Exception�swallow_exception�	threading�Thread�_worker�_worker_thread�start)�selfZwhoser�fd�streamr�r#�Mc:\Users\shubh\Videos\agent\nova\Lib\site-packages\debugpy/launcher/output.py�__init__s6
  14  ��	zCaptureOutput.__init__cCs8|j}|durzt�|�WdStyYdSwdS)N)r�os�closer)r r!r#r#r$�__del__7s��zCaptureOutput.__del__cCs`|jdur'z	t�|jd�}Wn	tyYnwt|�sn
  15  |�|�|jdus|jddd�dS)Ni�T��final)rr&�readr�len�_process_chunk)r �sr#r#r$r?s
  16  �
  17  
  18  �
  19  zCaptureOutput._workerFcCs|jj||d�}t|�dkrdSztj�d|j|�dd�d��Wn	ty*Ynw|j	dur2dSz?|�
  20  |d�\}}t|�}d}||kro|j	�||d��}|j	��|dkrdt
  21  �|j�d|_WdS||7}||ksEWdSWdSty�t�d||j�YdSw)	Nr*r�outputz
  22  �
  23  )rr0rzError printing {0!r} to {1})r�decoder-rZchannelZ
  24  send_eventr�replacerrr�write�flushr&r'rrr)r r/r+�_�size�iZwrittenr#r#r$r.Ls8��
  25  
  26  �
  27  �zCaptureOutput._process_chunkN)F)	�__name__�
  28  __module__�__qualname__�__doc__rr%r(rr.r#r#r#r$r
  29  s"
  30  rcCs2tj��D]\}}t�d||j�|j��qdS)z=Waits for all remaining output to be captured and propagated.z!Waiting for remaining {0} of {1}.N)rr�itemsrr
  31  rr�join)r�instancer#r#r$�wait_for_remaining_outputms�r@)
  32  rr&rZdebugpyrZdebugpy.commonr�objectrr@r#r#r#r$�<module>s`