
    h#                        S SK Jr  S SKrS SKrS SKrS SKrS SKJrJrJr  S SK	J
r
JrJrJr  S SKJrJrJrJrJr   " S S\R(                  5      rS rS	 rg)
    )annotationsN)adaptercommonlauncher)jsonlog	messagingsockets)clients
components	launchersserverssessionsc                    ^  \ rS rSr% Sr\R                  R                  rS\S'     " S S\R                  5      r	 " S S\R                  5      r
U 4S	 jrS
 rS r\S 5       r\S 5       r\S 5       rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       rU 4S jrS rS rSrU =r$ )Client   z+Handles the client side of a debug session.zset[servers.Connection]known_subprocessesc                  &    \ rS rSrSSSSSSS.rSrg)Client.Capabilities   F)supportsVariableTypesupportsVariablePagingsupportsRunInTerminalRequestsupportsMemoryReferences#supportsArgsCanBeInterpretedByShellsupportsStartDebuggingRequest N)__name__
__module____qualname____firstlineno__
PROPERTIES__static_attributes__r       jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\debugpy/adapter/clients.pyCapabilitiesr      s    $)&+,1(-38-2

r$   r&   c                  @    \ rS rSrSSS\R
                  " SSS9S.rSrg)	Client.Expectations$   zen-USTpathoptional)localelinesStartAt1columnsStartAt1
pathFormatr   N)r   r   r    r!   r   enumr"   r#   r   r$   r%   Expectationsr(   $   s     !#))FT:	

r$   r2   c                
  > US:X  a  [         R                  " SU 5        SU l        [        R                  R                  5       n[        [        R                  S5      =[        l
        n[        R                  " UR                  5        [        [        R                  S5      =[        l        n[        R                  " UR                  5        O&SU l        [        R                  R                  U5      n[         R"                  " 5        n[$        TU ]M  XR5        S U l         SU l         S U l         SU l         S U l         / U l         SU l        [7        5       U l        Xl        UR                  5         S S S 5        U R<                  R?                  SSS	S
[@        RB                  0S.5        U R<                  R?                  SSSS
[@        RB                  0S.5        [         RD                  " 5         g ! , (       d  f       N= f)Nstdioz"Connecting to client over stdio...TrwFoutput	telemetryptvsdpackageVersion)categoryr7   datadebugpy)#r   infousing_stdior	   JsonIOStream
from_stdioopenosdevnullsysstdinatexitregisterclosestdoutfrom_socketr   Sessionsuper__init__	client_idhas_startedstart_requestrestart_requested_initialize_request_deferred_events_forward_terminate_requestsetr   clientchannel
send_eventr=   __version__report_sockets)selfsockstreamrF   rJ   session	__class__s         r%   rN   Client.__init__,   s   7?HH94@#D++668F !%RZZ 55CIOOEKK("&rzz3"77CJOOFLL)$D++77=F7GW-!DNV$D "&D &+D" (,D$ %'D! /4D+&)eD#!NE  L 	'!)7+>+>?	
 	'#)7+>+>?	
 	!m  s   
A,G44
Hc                    U R                   b2  U R                   R                  U5        [        R                  " S5        g U R                  R
                  R                  U5        g )NzPropagation deferred.)rT   appendr   debugrW   rX   	propagater\   events     r%   propagate_after_startClient.propagate_after_starts   sI    
   ,!!((/II-.KK))%0r$   c                P   [         R                  " SU R                  5        U R                   HM  n[         R                  " SUR	                  5       5        U R                  R
                  R                  U5        MO     [         R                  " SU R                  5        S U l        g )Nz%Propagating deferred events to {0}...zPropagating deferred {0}z&All deferred events propagated to {0}.)r   rd   rW   rT   describerX   re   r>   rf   s     r%   _propagate_deferred_events!Client._propagate_deferred_events~   sp    		94;;G**EII0%..2BCKK))%0 + 	94;;G $r$   c                r    U R                   (       a&  U R                   R                  R                  U5        g g N)serverrX   re   rf   s     r%   rg   Client.event   s&    ;;KK))%0 r$   c                L    U R                   R                  R                  U5      $ ro   )rp   rX   delegater\   requests     r%   ru   Client.request   s    {{""++G44r$   c                ^   U R                   b  UR                  S5      eU" SS5      U l        U R                  X5      U l        U R                  X5      U l        Xl         SSSSS.S	S
SSS.SSSSS./n0 SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S S_SSUSS!.E$ )"NzSession is already initializedclientID raisedzRaised ExceptionsFz'Break whenever any exception is raised.)filterlabeldefaultdescriptionuncaughtzUncaught ExceptionsTz=Break when the process is exiting due to unhandled exception.userUnhandledzUser Uncaught Exceptionsz/Break when exception escapes into library code.supportsCompletionsRequestsupportsConditionalBreakpoints supportsConfigurationDoneRequestsupportsDebuggerProperties supportsDelayedStackTraceLoadingsupportsEvaluateForHoverssupportsExceptionInfoRequestsupportsExceptionOptionssupportsFunctionBreakpoints!supportsHitConditionalBreakpointssupportsLogPointssupportsModulesRequestsupportsSetExpressionsupportsSetVariablesupportsValueFormattingOptionssupportsTerminateDebuggeesupportsTerminateRequest)supportsGotoTargetsRequestsupportsClipboardContextexceptionBreakpointFilterssupportsStepInTargetsRequest)rS   
isnt_validrO   r&   capabilitiesr2   expectations)r\   ru   exception_breakpoint_filterss      r%   initialize_requestClient.initialize_request   s   ##/$$%EFF R0 --d< --d<#*  #, H	 %.^	 *3 P	(
$*
($
,d
 /
 )$	

 /
 (
 +D
 '
 *4
 0
  
 %d
 $T
 "4
 -d
  (!
" '#
$ +/(,*F,0+
 	
r$   c                N   ^  [         R                  R                  U 4S j5       nU$ )Nc           	     \  > UR                  SS5      (       d   eU R                  c  UR                  S5      eU R                  (       d  U R                  (       a  UR                  S5      eU" S[
        R                  " S5      5      U R                  l        U R                  R                  (       a  [        R                  " 5         [        U" S[
        R                  " [        5      5      5      =U R                  l        nT" X5        UR                  b  g U R                  (       a  U R                  R!                  U R                  5        S U l        UR"                  nU R                  (       ac  UR%                  S5      S	:H  nS
U;   a  ['        U5      n[)        US
1-
  5      US'   SnUR%                  S5      (       a  ['        U5      nUS	 SnXCS'    U R                  R*                  R-                  UR.                  U5        U R                  R                  (       a/  Xl         SU l!        UR5                  0 5        U RE                  5         g U R*                  RG                  S5        Xl         [0        RH                  $ ! [0        R2                   ag    UR5                  0 5        U R                  R7                  SR9                  U R                  [
        R:                  " UR.                  5      5      5         g [0        R<                   a  nUR?                  U5         S nAGNS nAff = f)NlaunchattachzSession is not initialized yetzSession is already startednoDebugFdebugOptionsconsoleinternalConsoleRedirectOutputTredirectOutputisOutputRedirected){0} disconnected before responding to {1}initialized)%
is_requestrS   r   r   rp   r   r}   r_   no_debugr   dont_wait_for_first_connectionrV   arraystrdebug_optionsresponse
initialize	argumentsgetdictlistrX   ru   commandr	   NoMoreMessagesrespondfinalizeformatreprMessageHandlingErrorre   rQ   rP   rl   rY   NO_RESPONSE)r\   ru   r   r   redirectingexcfs         r%   handle-Client._start_message_handler.<locals>.handle   s   %%h9999''/(()IJJ}}(()EFF$+It||E7J$KDLL!||$$6689<

38: DLL& d+{{&&t'?'?@+/(#--	=="+--	":>O"OK'=8 %)O	48)-=,>>5	.1 '+ }}%566$(O	%&67&*6A23
+KK''//K" ||$$%,"#' #//1 LL##M2!((((7 !// 
 OOB'LL))CJJ KK IIgoo6  55 +MM'**+s   0J A8L+<L+L&&L+)r   	Componentmessage_handler)r   r   s   ` r%   _start_message_handlerClient._start_message_handler   s+    				-	-J	) 
.J	)X r$   c                  ^^ SSK Jn  U R                  R                  S:w  d#  [	        [
        R                  " 5       5      (       a  TR                  S5      e[        T" S[        R                  " [        5      5      5      mUU4S jnSnUT;   a  ST;   a  TR                  S	5      eOST;   a  SnT" U[        R                  " [        S
SS95      n[	        U5      (       d  [        R                  /nUT" S[        R                  " [        SS95      -  nUSS  TR                  S'   UTR                  S'   T" S[        S
S9nUS:X  a  US   nS=n=pST;   a  T" S[        5      nU/n
UTR                  S'   ST;   a   T" S[        5      nSU/n
UTR                  S'   ST;   aC  T" S[        R                  " [        S
SS95      n	SSR!                  U	5      /n
STR                  S'   [	        XxU	4 Vs/ s H  oS:w  d  M
  UPM     sn5      nUS:X  a  TR                  S5      eUS:w  a  TR                  S5      eT" S[        R"                  " SSSS
S95      nT" S [        R$                  " S!5      5      nT" S"[        R                  " [        S
S#95      nW
U-  n
[	        U5      S:  =(       a    ['        TR                  S"   [        5      nU(       a<  U R(                  S$   (       d  TR                  S%5      eUS:X  a  TR                  S&5      eT" S'[        S
S9nUS:X  a0  US:X  a  S O'[*        R,                  R/                  U5      =(       d    S n[1        U" S(S)5      5      nU(       a%  [        R2                  S*:X  a  TR                  S+5      eT" S,[        S
S9nU(       a
  US-:H  U l        T" S.[*        R,                  R/                  [6        R8                  5      5      n[:        R<                  " 5       nT" S/U5      n [
        R>                  " U5        URB                  " U R                  TU/UUU
UUUUU5        g s  snf ! [@         a"  nTR                  S0U R                  U5      eS nAff = f)1Nr   )r      z"attach" expectedr   c                $  > U S   R                  5       (       a  US   R                  5       (       d   eT" U [        SS9nUS:X  a  S nUT;   aB  USL a;  TR                  S[        R
                  " U 5      [        R
                  " U5      5      eSnU$ )Nr   Tr+   r   Fz9{0}:false and "debugOptions":[{1}] are mutually exclusive)islowerisupperboolr   r   r   )	prop_name	flag_namevaluer   ru   s      r%   property_or_debug_option7Client.launch_request.<locals>.property_or_debug_option*  s    Q<''))il.B.B.D.DDDItd;E{M)E>!,,S		),		), 
 Lr$   python
pythonPathz2"pythonPath" is not valid if "python" is specifiedT)r   )	vectorizesize
pythonArgs)r   debugLauncherPythonr+   r   programprocessNamemodulez-mcode)r   z-c
z7either "program", "module", or "code" must be specifiedz6"program", "module", and "code" are mutually exclusiver   r   integratedTerminalexternalTerminalconsoleTitlezPython Debug Consoleargs)r   r   z8Shell expansion in "args" is not supported by the clientzJShell expansion in "args" is not available for "console":"internalConsole"cwdsudoSudowin32z("sudo":true is not supported on Windows.onTerminateKeyboardInterruptdebugLauncherPathdebugAdapterHostz4{0} couldn't create listener socket for servers: {1})"debugpy.adapterr   r_   idlenr   connectionscant_handlerV   r   r   r   r   rE   
executabler   joinr1   r}   
isinstancer   rC   r*   dirnamer   platformrU   r   __file__r
   get_default_localhostserve	Exceptionspawn_debuggee)r\   ru   r   r   
python_keyr   launcher_pythonr   r   r   r   xnum_targetsr   console_titletarget_argsshell_expand_argsr   r   on_terminatelauncher_path	localhostadapter_hostr   r   s    `                      @r%   launch_requestClient.launch_request  sV   -<<??a3w':':'<#=#=%%&9::GNDJJsODE
	( 
 w&((H  ' W$%JTZZt$%OP6{{nn%F',

3T(BCC*0*,'&,(#!"7tLb $QiO"$$$&i-G9D/6Gm,wXs+F&>D/5Gm,W64::cT#MND$))D/*D/3Gm,w&=I&=b1&=IJ!$$I  A$$H  II!$"	
  =S0TU fdjj&EF  ,q0 
Zf%s6
 $$%JK((N  ++((`  eS40"9 "R-$bggoog.F.N$C,VV<=CLLG+%%&PQQ}cDA.:>Q.QD+ 3RWW__XEVEV5WX113	19=	MM,' 	  LL	
G Jx  	%%F 	s$   1	P<>P<>Q 
Q-Q((Q-c                <  ^ ^^ T R                   R                  (       a  UR                  S5      eU" S[        SS9nU" S[        SS9nU" S[
        SS9nU" S[
        SS9nU" S[        [        4SS9mU" S	[        SS9mU" S
[        SS9nU(       a
  US:H  T l        US:w  d  US:w  a.  US:w  a  UR                  S5      eUS:w  a  UR                  S5      eUS:w  aE  US:w  a  UR                  S5      eTS:w  a  UR                  S5      eTS:w  a  UR                  S5      eTS:w  a  TS:w  a  UR                  S5      e[        R                  " 5       nUS:w  as  [        R                  " 5       (       a  UR                  S5      eU" SU5      nU" S[        5      nS [        l        U" SS5      T l        [        R                  " X#5      u  p#OV[        R                  " 5       (       d  [        R                  " U5        [        R                   " [        R"                  5      u  p#TS:w  aw  [%        T[        5      (       d   [	        T5      mU" S[(        R*                  " [        5      5      nU 4S jn	 [        R,                  " TX5        [4        R6                  nU4S jnO*TS:X  a  S nUS:X  a  [4        R6                  OS nOU4S jnSnT R8                  R;                  SX#S.5        [        R<                  " T R                   X5      nUcb  TS:w  a<  UR?                  0 5        T R                   R3                  S RA                  T5      5        g URC                  U(       a  S!T5      eS"T5      e URE                  T R                   5        g ! [&         a    UR                  S5      ef = f! [&         aG  n
[.        R0                  " 5         T R                   R3                  S[        U
5      < 35         S n
A
g S n
A
ff = f! [F         a    URC                  S#U5         g f = f)$Nz'"noDebug" is not supported for "attach"hostTr+   portlistenconnect	processIdsubProcessIdr   r   r   z1"listen" and "host"/"port" are mutually exclusivez2"connect" and "host"/"port" are mutually exclusivez-"listen" and "connect" are mutually exclusivez/"listen" and "processId" are mutually exclusivez2"listen" and "subProcessId" are mutually exclusivez5"processId" and "subProcessId" are mutually exclusivez7Multiple concurrent "listen" sessions are not supportedrestartFz$"processId" must be parseable as intdebugpyArgsc                D   > TR                   R                  SU US.5        g )Nr7   )r;   r7   )rX   rY   )r;   r7   r\   s     r%   	on_output(Client.attach_request.<locals>.on_output  s#    ''$,"(r$   z$Error when trying to attach to PID:
c                "   > U R                   T:H  $ ro   pid)connr  s    r%   <lambda>'Client.attach_request.<locals>.<lambda>   s    Cr$   c                    g)NTr   )r  s    r%   r  r  #  s    Dr$   c                "   > U R                   T:H  $ ro   r  )r  sub_pids    r%   r  r  &  s    DHH$7r$   r   debugpyWaitingForServerr  r  z+No known subprocess with "subProcessId":{0}z.Timed out waiting for debug server to connect.z3There is no debug server connected to this adapter.z{0} is already being debugged.)$r_   r   r   r   intr   r   rU   r
   r   r   
is_servingr   access_tokenrR   r   get_addresslistenerr   r   r   r   injectr   swallow_exceptionr   r   PROCESS_SPAWN_TIMEOUTrX   rY   wait_for_connectionr   r   r   attach_to_session
ValueError)r\   ru   r  r  r  r  r   r   debugpy_argsr  etimeoutpredr  r  r  s   `             @@r%   attach_requestClient.attach_request  s   <<  $$%NOOvsT2vsT24$7)TD9kC:=.#=}dTB.:>Q.QD+2:|((G  "}((H  R<"}((C  by((E  "}((H  "9B$$G  113	R<!!##((M  &),D&#&D#'G %,Y%>D" t2JD$%%''i( ,,W-=-=>JD6 "9c3''Uc(C #=$**S/BLsL< 22G/D"}(:@B,&66D7 9D;WX**4<<G<"}
 #%%AHHQ %%  E   O 	H""4<<0q ! U!,,-STTU  %%'%%ADQI T  	H @$G	Hs6   =N	 0N( -O< 	N%(
O92=O44O9<PPc           	        U R                   b  U R                  (       a  UR                  S5         SU l         U R                  R                  R                  U5      nUR                  U5        U R                   R                  c+  U R                   R                  0 5        U R!                  5         [&        R(                  " 5        HI  nUR                  b  M  UR*                  U R                  R,                  :X  d  M8  U R/                  U5        MK     g ! [        R                   a    UR                  0 5        U R                   R                  0 5        U R                  R                  SR                  U R                  [        R                  " UR                  5      5      5         U R                   R                  c,  U R                   R                  0 5        U R!                  5         g g f = f! [        R"                   a/  nU R                   R                  [%        U5      5         S nAGNS nAff = f! U R                   R                  c,  U R                   R                  0 5        U R!                  5         f f = f)NzX"configurationDone" is only allowed during handling of a "launch" or an "attach" requestTr   )rQ   rP   r   rp   rX   rs   r   r	   r   r_   r   r   r   r   r   r   rl   r   r   r   r   ppidr  notify_of_subprocess)r\   ru   resultr   r  s        r%   configurationDone_request Client.configurationDone_requestE  s   %)9)9)
	2#D(,,55g>  ' !!**2""**2.//1 '')D{{"tyyDLL4D4D'D))$/ *3 ++ 
 #""**2.%%?FF		'//2  !!**2""**2.//1 3'  -- 	5**3s844	5 !!**2""**2.//1 3sN   G0 %D G0 BG-'G0 ,G--G0 0H3$H.(H6 .H33H6 6AI;c                   ^ U R                   R                  R                  T5      nU4S jnUR                  U5        [        R
                  $ )Nc                <   > TR                  U R                  5        g ro   )r   body)r   ru   s    r%   handle_response0Client.evaluate_request.<locals>.handle_responser  s    OOHMM*r$   )rp   rX   re   on_responser	   r   )r\   ru   propagated_requestr5  s    `  r%   evaluate_requestClient.evaluate_requestn  s?    ![[00::7C	+ 	&&7$$$r$   c                j    SUR                   S'   U R                  R                  R                  U5      $ )N*threadId)r   rp   rX   rs   rt   s     r%   pause_requestClient.pause_requesty  s-    (+*%{{""++G44r$   c                    SUR                   S'    U R                  R                  R                  U5      $ ! [        R
                   a    SS0s $ f = f)Nr<  r=  allThreadsContinuedT)r   rp   rX   rs   r	   r   rt   s     r%   continue_requestClient.continue_request~  sT    (+*%	1;;&&//88'' 	1 *400		1s   $6 AAc                    SS[         R                  00nU R                  (       a9   U R                  R                  R	                  S5      nUR                  U5        U$ U$ ! [         a     U$ f = f)Nr=   versionpydevdSystemInfo)r=   rZ   rp   rX   ru   updater   )r\   ru   r/  pydevd_infos       r%   debugpySystemInfo_request Client.debugpySystemInfo_request  sr    i)<)<=>;;+"kk1199:LM k*v    s   %A! !
A/.A/c                    SU l         U R                  (       a%  U R                  R                  R	                  U5      $ U R
                  R                  SSS9  0 $ )NFzclient requested "terminate"T)terminate_debuggee)rR   rU   rp   rX   rs   r_   r   rt   s     r%   terminate_requestClient.terminate_request  sP     "'** ;;&&//88<QUV	r$   c                F   SU l         U" S[        SS9nUS:X  a  S nU R                  R                  SU5        UR	                  0 5        U R
                  (       ac  [        R                  " 5         [        R                  " SU 5        [        R                  " 5        H  n UR                  R                  5         M       U R                  R                  5         g ! [         a    [        R                  " 5          M`  f = f! [         a    [        R                  " SS	9   g f = f)
NFterminateDebuggeeTr+   r   zclient requested "disconnect"zB{0} disconnected from stdio; closing remaining server connections.warninglevel)rR   r   r_   r   r   r?   r   stop_servingr   r>   r   rX   rI   r   r!  )r\   ru   rL  r  s       r%   disconnect_requestClient.disconnect_request  s     "'$%8$N#!%=?QR   "HHY[_`++-,LL&&( .	3LL  ! ,))+,  	3!!	2	3s$   C>C? C<;C<?D D c                "   > [         TU ]  5         g ro   )rM   
disconnect)r\   r`   s    r%   rX  Client.disconnect  s    r$   c           	     6   [         R                  [        R                  [        R                  4 VVVs/ s H6  nUc  M  [        R
                  " U5      u  p#UUU[         R                  LS.PM8     nnnnU R                  R                  SSU05        g s  snnnf )N)r  r  internaldebugpySocketsr
   )r   r  r   r   r
   r  rX   rY   )r\   r  r  r  sockss        r%   r[   Client.report_sockets  s     %--y/A/A7CSCST	
 U ")!4!4X!> $G,<,<<
 U 	 	
 	5	
	
s
   B2Bc                   [         R                  " SX5        U R                     U R                  b  XR                  ;   a
   S S S 5        g SU R                  R
                  ;   a+  [         R                  " SU R                  5         S S S 5        g [         R                  " SX5        [        U R                  R
                  5      nU R                  R                  U5        U R                  R                  5         S S S 5        S H  nWR                  US 5        M     SR                  UR                  5      WS'   UR                  US'   S	 H  nUR                  US 5        M     UR                  S
S 5      nUR                  SS 5      nSU;  a  0 US'   S
US   ;  a&  [        R                  " 5       nU=(       d    UUS   S
'   SUS   ;  a&  Uc  [        R                  " [         5      u  puXRS   S'   U R"                  S   (       a   U R$                  R'                  SSUS.5        g SUS'   U R$                  R)                  SU5        g ! , (       d  f       GNU= f)Nz{1} is a subprocess of {0}.r	  zrNot reporting subprocess for {0}, because the parent process was attached to using "processId" rather than "port".zNotifying {0} about {1}.)r	  r  preLaunchTaskpostDebugTaskru   r  zSubprocess {0}namer
  )r   r   r   r  r  r  r   startDebuggingr   )ru   configurationru   debugpyAttach)r   r>   r_   rQ   r   r   rQ  r   addnotify_changedpopr   r  r
   r   r  r  r   rX   ru   rY   )r\   r  r4  keyr  r  r   _s           r%   r.  Client.notify_of_subprocess  s   .;\\!!)T5L5L-L \ d00:::LLL
  \ HH/<**445D##''-LL'')   aCHHS$ a (..txx8V#xx^6CHHS$ 7 xx%xx%D  DOi(557I&*&7iDOF#i(|!--h7&*OF#<=LL  !1#!%4 
 'DOLL##OT:Y \s   I	<I	A+I		
I)rT   rU   rS   r   rO   r   rP   r   rR   rQ   r?   ) r   r   r    r!   __doc__r   r   r   __annotations__r&   r2   rN   rh   rl   rg   ru   r   r   r  r*  r0  r9  r>  rB  rI  rM  rU  rX  r[   r.  r#   __classcell__)r`   s   @r%   r   r      sl   5 **::O//
z.. 

z.. 
E"N	1% 1 1
 5 5 4
 4
tN` P
 P
d QH QHf &0 &0P % % 5 5 	1 	1    " 3 38
$.; .;r$   r   c                    [         R                  " S[        X5      q[        R
                  " 5         [         R                  " [        5      $ )Nr   )r
   r   r   r  r   r[   r  r  s     r%   r   r     s1    }}Xvt:Hx((r$   c                     [         b   [         R                  5         S q [
        R                  " 5         g ! [         a    [        R                  " SS9   N8f = f)NrQ  rR  )r  rI   r   r   r!  r   r[   r   r$   r%   rT  rT    sI    	3NN   	3!!	2	3s   5 AA)
__future__r   rG   rC   rE   r=   r   r   r   debugpy.commonr   r   r	   r
   r   r   r   r   r   r   r   r   r   rT  r   r$   r%   <module>rs     sG   
 #  	 
  - - 8 8 M My;Z!! y;x)r$   