bg:ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z n #e $rYnwxYwddl Z ddl Z ddlTddlmZddlmZddlmZddlmZGddejZd Zdd Zd ZGd d ejZGddejZGddZ dZ!e"dkr e!dSdS)N)*)Console) mutnodeset)ptable)cmdceZdZdS)ServerN)__name__ __module__ __qualname__f/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib64/python3.11/site-packages/guppy/heapy/Monitor.pyr r sDrr cXtj|ggg|\}}}t|SN)selectlen)fdwaitrwxs rioreadyrs*mRD"b$//GAq! q66Mrch |dS#tj$r|rYdSYnwxYw2)Ng?)timeout)getqueueEmpty)qnoblocks rqueue_get_interruptibler"$s[ 555%% %{       s 00)CLOSEDc>eZdZdZdZdZdZd dZdZdZ d Z d S) Handlerrc |jdss|jj||jt|j d|j dSdS)Nr) isclosedtasservermonitorremove_connectiondataqput CONN_CLOSEDrequestshutdowncloseselfs rr2z Handler.close5s}  ## ! K  1 1$ 7 7 7 JNN; ' ' ' L ! !! $ $ $ L    ! !rc|jds|dz }|j|jddS)N utf-8)endswithr0sendencoder4rs rsend_cmdzHandler.send_cmd<sGs|D!!  4KC *#*W--.....rc|jdkr|dd|jdkr|dd||dS)Nz>>> r r)retdataz cont)promptexec_cmdr;s r browser_cmdzHandler.browser_cmdAs^ ;& MM#qM ) ) ) ;* $ $ MM&!M , , ,}}S!},,,rrc6|||d|_g} t|j|}||jrnt jd5|t urt|ddkrKd|_|r||dnjtj |dnD|ddkr6|d|_ |j rd|_n d|_nJ|rd|SdS)NFrrDATAPROMPTT)r< promptstater"r-timesleepr/EOFErrorappendsysstdoutwriter@emptyjoin)r4rr>r!datasps rrAzHandler.exec_cmdHs6 ? MM#   $D  ' G<> ! " "rc|jdD]S}||rrD)r@rGrr(rQueuer-r*r+add_connectionrfilereadlinedecoderJr8resocketerrorREADLINErr.rArUr2)r4rbr@s rhandlezHandler.handlevsd  "  []]  **4000 / z**,,33G<<2"=111==&&+"6***+fl+    }}X&& /oH ~o. &1222;&%)]]tQ]%G%GDN ~... / sA&CCCN)rr) r r r allow_reuse_addressr2r<rBrAr]rcrnr rrr%r%2s!!!/// ---""""B"""rr%ceZdZdZdZdZdZdZdZdZ dZ d Z d Z e jjZd Zd Zd ZdZdZdZdZdZdZdZdZdZdS)MonitorConnectionrcri|_tj|d|_d|_d|_d|_||_tttftx|_ }||j _tj|jd|_|jdS)Nrz r )targetargs)aliasesrCmd__init__hnor( forceexitr@r+r LOCALHOST HEAPYPORTr%r* threadingThread run_serverststart)r4r+ss rrwzMonitorConnection.__init__s   "   )Y!7AAA a% "$/(*,,,  rcd|_|jjd|jd|j_dS)Nrr'cdSNrr )rys rz)MonitorConnection.close..s!r)r(r*rkr1 server_closeverify_requestr3s rr2zMonitorConnection.closesH  ##A&&&   """%3^ """rctj||tj|ddS)NrF)rrvdefaultdo_help)r4r[s rrzMonitorConnection.defaults4 d### b!!!!!rc|j}|js||j|dSr)r*r(handle_requestr)r4rs rr~zMonitorConnection.run_serversG K-      -  rc|sdS|} ||}||}|||}|S#t$r||YdSwxYwr)precmdonecmdpostcmd BaseException handle_error)r4rr[stops rrAzMonitorConnection.exec_cmds  F $;;t$$D;;t$$D<<d++DK $ $ $   d # # # # # # $sAA A-,A-c tdtjtddtjtt|tjddl}|jtdtjdS)ztHandle an error gracefully. May be overridden. The default is to print a traceback and continue. z(----------------------------------------)filez0Exception happened during processing the command )endrrN)printrLstderrrepr traceback print_exc)r4cmdliners rrzMonitorConnection.handle_errors f3:&&&& @CJ ( ( ( ( d7mm#*----  f3:&&&&&&rc r||_|s|S|}|d|jvr |j|d}d|vrd}|ddD]n}|dt |z|}|dt |zd||d}|dz}o|dd|dd}n#|dzd|ddz}|}|d|jv |ddkrp|d }|dkrU||d zd}|j ||d| }|S) z*Handle alias expansion and ';;' separator.r%rNz%>=rz%*aliasz;;r') curlinerVrureplacestrrPfindlstripcmdqueuerKrstrip)r4r[rtiitmpArgmarkernexts rrzMonitorConnection.precmds  Kzz||1g%%<Q(Dd{{"122h  F<<c"gg (.00D<<B(+bcc(;(;==DaBB||D#((48*<*<==czCHHT!""X$6$66::<AAc$tddS)Nzint ----- Local interactive console. This will bring up a Python console locally in the same interpreter process that the Monitor itself.rr3s rhelp_intzMonitorConnection.help_ints# 9 : : : : :rc|s|j}t|}|jj|}|drt ddSt d|z|tdS)NnoninterruptiblezCError: Can not interrupt this remote connection (uses Python < 2.4)z+Sending KeyboardInterrupt to connection %s.)conidintr+ connectionsr]rr<KEYBOARDINTERRUPT)r4rcs rdo_kizMonitorConnection.do_kis *C#hh L $S ) 88& ' ' * G H H H H H ?#E F F F JJ( ) ) ) ) )rc$tddS)Na\ki ----- Keyboard Interrupt Send a command to interrupt the remote thread on the specified connection (default is the last one connected to). Notes: It currently only works with Python >= 2.4. The remote thread will not always be awakened, for example if it is waiting in time.sleep(). Sometimes using several ki commands helps.rr3s rhelp_kizMonitorConnection.help_ki%s# < = = = = =rcgdg}t|jjD]C\}}|||d|dgDt ||jdS)N)CIDPIDARGVz target.pidztarget.sys.argv)listr+ritemsrKr]rrM)r4rtablecidrs rdo_lczMonitorConnection.do_lc3s'''(T\5;;==>> : :HC LL#**\22**%6779 : : : : udk"""""rc$tddS)Nalc ----- List Connections. List the currently open connections. The table printed has one line per connection in this form: CID PID ARGV 1 17999 ['/home/nilsson/bin/solitaire.py'] CID is the connection ID, which may be used as argument to the sc command. PID is the process ID of the target interpreter process. In Linux, this is the parent of the remote control interpreter thread that runs the Annex that the connection is talking to. ARGV is the argument vector in the target Python interpereter.rr3s rhelp_lczMonitorConnection.help_lc<s) B C C C C Crc|rt||_td|jz|j|jj|jdS)NzFRemote connection %d. To return to Monitor, type or .)rrrr+set_connectionrrs rdo_sczMonitorConnection.do_scOsW  "SDJ VY]Yccddd ##DL$ ----- Set connection to communicate with a remote thread. With an argument, set current connection to the number specified. Without argument, use the same connection as last time. You will then be talking to a remote process via that connection. You can return to Monitor at any time by . You may also use the '.' command (followed by ), if the remote process is waiting for input. The '.' character may be followed by a monitor command, to execute it directly instead of returning to the monitor. For example, when talking to a connection, '.sc 1' will directly change to connection 1.rr3s rhelp_sczMonitorConnection.help_scUs) J K K K K KrcdSrr rs rdo_qzMonitorConnection.do_qcsqrc$tddS)Nzq ----- Quit from the monitor. This will not exit from Python itself if called from an interactive interpreter. To make sure to exit from Python, use the exit command.rr3s rhelp_qzMonitorConnection.help_qfs) H I I I I IrN)r r r use_raw_inputrwr2rr~rArrrrrrvrdo_hrrrrrrrrrrrrr rrrqrqspM   444 """ $ $ $ ' ' ' > 7?DDDD    ::: * * * = = =###CCC&JJJ K K KIIIIIrrqcBeZdZdZdZdZdZdZdZdZ dZ d Z d S) Monitorrcft|x|_|_i|_d|_d|_dSr)rq connectionmonitor_connectionridsr@r3s rrwzMonitor.__init__qs34Ed4K4KK$1 rc|jsd|_|j|j_nIt dgdt |jDzdz|_|jS)Nrcg|]}|Sr r ).0rs r z!Monitor.newid..|sIIIaIIIr)rrrrmaxrkeysr3s rnewidz Monitor.newidwsm MDH,0HD # ) )A3II40@0E0E0G0G+H+HIIIIJJ1LDHxrc|}||j|<||_|d|zdS)Nz*** Connection %s opened ***)rr monitor_id print_async)r4rhids rrgzMonitor.add_connectionsDjjll * #  7#=>>>>>rc|jVtd|ztj|jtjdSdS)zS Print text only if we are waiting for input, and then restore the prompt. Nr6)r@rrLrMrNflush)r4texts rrzMonitor.print_asyncsX ; " $t)    J  T[ ) ) ) J        # "rc|j|j=||jur||j|d|jzdS)Nz*** Connection %s closed ***)rrrrrrr4rs rr,zMonitor.remove_connectionsd  Z2 3  ( (    7 8 8 8 7#./ 0 0 0 0 0rc d}|s1 |s|j}|j|_||jur|ddt |j}d|_d}|jdr%|dkr |j|_n|dd}|j}n|j}|r6 ||}n#t $rd}YnwxYw||jur|rd}|nd#t $r! td|j|_d}Yn:t$r.tdtd|j|_Y-wxYw|1d|_| dS#d|_| wxYw)Nrr)rr!.z%*** End Of File - Exiting Monitor ***KeyboardInterruptz1Use the ki command to interrupt a remote process.) rr@rrAinputrWrJrrr2)r4rconnrrs rrunz Monitor.runs) D# "")#&*k t'>>> MMdAM>>>#DK00&* #)3>#..3"czz262I&)!""g'+'>$(?D)&$(MM#$6$6#+&&&$%&#t'>>>1>'(/#)0 EABBB&*&=DODDD(-...MNNN&*&=DOH ?# LDK JJLLLLLDK JJLLLLs_EBCB/.C/ B>;C=B>>CE(D29E;3D2.E1D22EE2cPt|jD],} |#tj$rY)wxYw |jn#tj$rYnwxYw|jjrtj ddSdSr) rrvaluesr2rkrlrryos_exit)r4rs rr2z Monitor.closesd&--//00  A  <       # ) ) + + + +|    D   " ,  HQKKKKK  s!?AAA//BBc,||_|j|_dSr)rr@rs rrzMonitor.set_connections$ ' rN) r r r rrwrrgrr,rr2rr rrrrnsM ??? 000***X   (((((rrc~ddlm}|t}|dS)zmonitor() [0] Start an interactive remote monitor. This can be used to get information about the state, in particular the memory usage, of separately running Python processes. References [0] heapy_Use.html#heapykinds.Use.monitorr)RemoteN) guppy.heapyroffrr)rms rr+r+s=#""""" JJLLL AEEGGGGGr__main__)r)#rpprintsignalrk socketserverrLr|rHrr_ri ImportErrorrrguppy.heapy.RemoteConstantsguppy.heapy.Consoler guppy.setsr guppy.etc.etcr guppy.etcrThreadingTCPServerr rr"r/StreamRequestHandlerr%rvrqrr+r r rrrs1    OOOO   D  ))))''''''!!!!!!      \ ,     \\\\\l/\\\~ZIZIZIZIZIZIZIZIza(a(a(a(a(a(a(a(H   " z GIIIIIs /77