b374k
m1n1 1.01
Apache/2.2.15 (CentOS)
Linux obd60-6c49958d75-2q7cw 5.4.0-174-generic #193-Ubuntu SMP Thu Mar 7 14:29:28 UTC 2024 x86_64
uid=48(apache) gid=48(apache) groups=48(apache)
server ip : 104.21.65.202 | your ip : 10.244.126.0
safemode OFF
 >  / usr / lib64 / python2.6 / idlelib /
Filename/usr/lib64/python2.6/idlelib/rpc.pyc
Size21.42 kb
Permissionrw-r--r--
Ownerapache
Create time23-Dec-2025 17:41
Last modified20-Jun-2019 19:45
Last accessed20-Jun-2019 19:45
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
Ñò
§ÚêLc@sÖdZddkZddkZddkZddkZddkZddkZddkZddk Z ddk
Z
ddk Z ddk Z ddk
Z
ddkZd�Zd�Ze ie
iee�ddZdZdeifd ��YZhZe
i
d
�Ze
i
d
�Zd efd ��YZd
efd��YZd�Zdefd��YZdeiefd��YZdefd��YZ defd��YZ!d�Z"d�Z#defd��YZ$dS(sRPC Implemention, originally written for the Python Idle IDE

For security reasons, GvR requested that Idle's Python execution server process
connect to the Idle process, which listens for the connection. Since Idle has
has only one client per server, this was not a limitation.

+---------------------------------+ +-------------+
| SocketServer.BaseRequestHandler | | SocketIO |
+---------------------------------+ +-------------+
^ | register() |
| | unregister()|
| +-------------+
| ^ ^
| | |
| + -------------------+ |
| | |
+-------------------------+ +-----------------+
| RPCHandler | | RPCClient |
| [attribute of RPCServer]| | |
+-------------------------+ +-----------------+

The RPCServer handler class is expected to provide register/unregister methods.
RPCHandler inherits the mix-in class SocketIO, which provides these methods.

See the Idle run.main() docstring for further information on how this was
accomplished in Idle.

iÿÿÿÿNcCs-ti|�}t|ti�pt�|S(N(tmarshaltloadst
isinstancettypestCodeTypetAssertionError(tmstco((s#/usr/lib64/python2.6/idlelib/rpc.pyt
unpickle_code-scCs6t|ti�pt�ti|�}t|ffS(N(RRRRRtdumpsR(RR((s#/usr/lib64/python2.6/idlelib/rpc.pyt pickle_code2siis 127.0.0.1t RPCServercBs8eZdd�Zd�Zd�Zd�Zd�ZRS(cCs1|djo
t}ntii|||�dS(N(tNonet
RPCHandlert SocketServert TCPServert__init__(tselftaddrt handlerclass((s#/usr/lib64/python2.6/idlelib/rpc.pyRGs

cCsdS(s@Override TCPServer method, no bind() phase for connecting entityN((R((s#/usr/lib64/python2.6/idlelib/rpc.pyt server_bindLscCs|ii|i�dS(sÎOverride TCPServer method, connect() instead of listen()

Due to the reversed connection, self.server_address is actually the
address of the Idle Client to which we are connecting.

N(tsockettconnecttserver_address(R((s#/usr/lib64/python2.6/idlelib/rpc.pytserver_activatePscCs|i|ifS(s:Override TCPServer method, return already connected socket(RR(R((s#/usr/lib64/python2.6/idlelib/rpc.pyt get_requestYscCsÄy�Wn¶tj
o
�n¢ti}|dddIJ|dIJ|dti�i�IJ|dI|IJ|dIt|�IJtid|�|d IJ|ddIJt i
d
�nXd S( sÜOverride TCPServer method

Error message goes to __stderr__. No error message if exiting
normally or socket raised EOF. Other exceptions not handled in
server code will cause os._exit.

s
t-i(sUnhandled server exception!s
Thread: %ssClient Address: s Request: tfiles#
*** Unrecoverable, server exiting!iN( t
SystemExittsyst
__stderr__t threadingt
currentThreadtgetNametreprt tracebackt print_exctost_exit(Rtrequesttclient_addressterf((s#/usr/lib64/python2.6/idlelib/rpc.pyt handle_error]s 

N(t__name__t
__module__R RRRRR*(((s#/usr/lib64/python2.6/idlelib/rpc.pyR Es
   itSocketIOcBseZdZddd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d�Z d �Z d
�Z
d �Zd �Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z!RS(icCshti�|_|dj o
||_n||_|djo
t}n||_h|_h|_ dS(N(
RR t
sockthreadR t debuggingtsockt objecttabletobjtablet responsestcvars(RR0R2R/((s#/usr/lib64/python2.6/idlelib/rpc.pyR�s

 

  cCs1|i}d|_|dj o|i�ndS(N(R0R tclose(RR0((s#/usr/lib64/python2.6/idlelib/rpc.pyR5�s  
cCsti�dS(s!override for specific exit actionN(R%R&(R((s#/usr/lib64/python2.6/idlelib/rpc.pytexithook�scGsh|ipdS|idtti�i��}x"|D]}|dt|�}q9Wti|IJdS(Nt (R/tlocationtstrRR R!RR(Rtargststa((s#/usr/lib64/python2.6/idlelib/rpc.pytdebug�s
#cCs||i|<dS(N(R2(Rtoidtobject((s#/usr/lib64/python2.6/idlelib/rpc.pytregister�scCs(y|i|=Wntj
onXdS(N(R2tKeyError(RR>((s#/usr/lib64/python2.6/idlelib/rpc.pyt
unregister sc Csò|id|�y|\}\}}}}Wntj
odSX|ii|�pdd|ffS|i|}|djoh} t|| �d| fS|djoh}
t||
�d|
fSt||�pdd|ffSt||�} y�|d jo:| ||�} t| t �ot
| �} nd| fS|d
jo!t i || ||ff�dSdd |fSWnhtj
o
�nTtij
o
�n<d
}
ti|
|| |fIJtidti�dSXdS(Ns
localcall:tERRORsBad request formatsUnknown object id: %rt __methods__tOKt__attributes__sUnsupported method name: %rtCALLtQUEUEtQUEUEDsUnsupported message type: %ssU*** Internal Error: rpc.py:SocketIO.localcall()

Object: %s
Method: %s
Args: %s
Rt EXCEPTION(RCsBad request format(RIN(RJN(R=t TypeErrorR2thas_keyt _getmethodst_getattributesthasattrtgetattrRt RemoteObjectt remotereft
request_queuetputR RRterrorRRR#R$(RtseqR'thowR>t
methodnameR:tkwargstobjtmethodst
attributestmethodtrettmsg((s#/usr/lib64/python2.6/idlelib/rpc.pyt localcall¦sL


 

 
 
cCs8|id||�|i||||�}|i|�S(Nsremotecall:asynccall: (R=t asynccallt asyncreturn(RR>RXR:RYRV((s#/usr/lib64/python2.6/idlelib/rpc.pyt
remotecallÐscCs8|id||�|i||||�}|i|�S(Nsremotequeue:asyncqueue: (R=t
asyncqueueRb(RR>RXR:RYRV((s#/usr/lib64/python2.6/idlelib/rpc.pyt remotequeueÕscCs�d||||ff}|i�}ti�|ijoti�}||i|<n|id|||||�|i||f�|S(NRGs
asynccall:%d:(tnewseqRR R.t ConditionR4R=t
putmessage(RR>RXR:RYR'RVtcvar((s#/usr/lib64/python2.6/idlelib/rpc.pyRaÚs  cCs�d||||ff}|i�}ti�|ijoti�}||i|<n|id|||||�|i||f�|S(NRHsasyncqueue:%d:(RfRR R.RgR4R=Rh(RR>RXR:RYR'RVRi((s#/usr/lib64/python2.6/idlelib/rpc.pyRdäs  cCsG|id|�|i|dd�}|id||�|i|�S(Ns#asyncreturn:%d:call getresponse(): twaitg������©?sasyncreturn:%d:response: (R=t getresponsetdecoderesponse(RRVtresponse((s#/usr/lib64/python2.6/idlelib/rpc.pyRbîscCsµ|\}}|djo|S|djodS|djo|id�dS|djo|id�|i�dS|djo|id|�t|�nt||f�dS( NRERIRJsdecoderesponse: EXCEPTIONtEOFsdecoderesponse: EOFRCsdecoderesponse: Internal ERROR:(R R=tdecode_interrupthookt RuntimeErrort SystemError(RRmRWtwhat((s#/usr/lib64/python2.6/idlelib/rpc.pyRlôs  








cCs
t�dS(tN(tEOFError(R((s#/usr/lib64/python2.6/idlelib/rpc.pyRoscCsBy|idddd�Wn!tj
o|id�dSXdS(s¥Listen on socket until I/O not ready or EOF

pollresponse() will loop looking for seq number None, which
never comes, and exit on EOFError.

tmyseqRjg������©?smainloop:returnN(RkR RtR=(R((s#/usr/lib64/python2.6/idlelib/rpc.pytmainloop
s

cCsY|i||�}|dj o6|\}}|djo||i|�f}qUn|S(NRE(t _getresponseR t_proxify(RRuRjRmRWRr((s#/usr/lib64/python2.6/idlelib/rpc.pyRks 
 
cCsIt|t�ot||i�St|ti�ot|i|�S|S(N(Rt RemoteProxytRPCProxyR>RtListTypetmapRx(RRZ((s#/usr/lib64/python2.6/idlelib/rpc.pyRxs
cCsÚ|id|�ti�|ijo.x­|i||�}|dj o|Sq)n�|i|}|i�x"|ii |�p|i
�qnW|i|}|id||f�|i|=|i|=|i �|SdS(Ns_getresponse:myseq:s-_getresponse:%s: thread woke up: response: %s( R=RR R.t pollresponseR R4tacquireR3RLRjtrelease(RRuRjRmRi((s#/usr/lib64/python2.6/idlelib/rpc.pyRw's$
 


 


cCs|id|_}|S(Ni(tnextseq(RRV((s#/usr/lib64/python2.6/idlelib/rpc.pyRf=sc
Cs|id|d�yti|�}Wn2tij
o#tidIt|�IJ�nXtidt |��|}x�t |�djo�y>t
i
g|i gg�\}}}|i i |t
�}Wn:ttfj
otd�q|tij
o
�q|X||}q|WdS(Nsputmessage:%d:isCannot pickle:s<issocket no longer exists(R=tpickleR t
PicklingErrorRRR"tstructtpacktlentselectR0tsendtBUFSIZEtAttributeErrorRKtIOErrorRRU(RtmessageR;trtwtxtn((s#/usr/lib64/python2.6/idlelib/rpc.pyRhAs"$
RsicCsá|i�t|i�|ijo´ti|ii�ggg|�\}}}t|�djodSy|iit �}Wnt
i j
o
t �nXt|�djo
t �n|i|7_|i�n|i
�S(Ni(t_stage0R�tbuffertbufneedR�R0tfilenoR trecvR�RRURtt_stage1(RRjR�R�R�R;((s#/usr/lib64/python2.6/idlelib/rpc.pyt
pollpacketXs
- 
cCsm|idjoYt|i�djoC|id }|id|_tid|�d|_d|_ndS(Niis<ii(tbufstateR�R�R�tunpackR�(RR;((s#/usr/lib64/python2.6/idlelib/rpc.pyR�hs
&
cCsg|idjoSt|i�|ijo:|i|i }|i|i|_d|_d|_|SdS(Niii(R�R�R�R�(Rtpacket((s#/usr/lib64/python2.6/idlelib/rpc.pyR�os )  cCs�|i|�}|djodSyti|�}Wn_tij
oPtidIJtidIt|�IJti dti�tidIJ�nX|S(Ns-----------------------scannot unpickle packet:R(
R�R R�RtUnpicklingErrorRRR"R#t print_stack(RRjR�R�((s#/usr/lib64/python2.6/idlelib/rpc.pyt pollmessagews


c

CsÐxÉytid�}Wntij
on-X|\}}|d|ff}|i|�y%|i|�}|djodSWn1tj
o|i�dSt j
odSX|\}}|d}|i
d||f�|d jov|i
d|�|i ||�}|i
d||f�|djo|i||f�q|djoqqq||jo|S|i i|d�} | dj o/| i
�||i|<| i�| i�qqqdS(
sRHandle messages received on the socket.

Some messages received may be asynchronous 'call' or 'queue' requests,
and some may be responses for other threads.

'call' requests are passed to self.localcall() with the expectation of
immediate execution, during which time the socket is not serviced.

'queue' requests are used for tasks (which may block or hang) to be
processed in a different thread. These requests are fed into
request_queue by self.localcall(). Responses to queued requests are
taken from response_queue and sent across the link with the associated
sequence numbers. Messages in the queues are (sequence_number,
request/response) tuples and code using this module removing messages
from the request_queue is responsible for returning the correct
sequence number in the response_queue.

pollresponse() will loop until a response message with the myseq
sequence number is received, and will save other responses in
self.responses and notify the owning thread.

iREspollresponse:%d:myseq:%sRGRHspollresponse:%d:localcall:call:s%pollresponse:%d:localcall:response:%sN(sCALLsQUEUE(tresponse_queuetgettQueuetEmptyRhR�R Rtt
handle_EOFR�R=R`R4R~R3tnotifyR(
RRuRjtqmsgRVRmR�tresqRWtcv((s#/usr/lib64/python2.6/idlelib/rpc.pyR}�sN 

 
 

 






cCsq|i�|id�xI|iD]>}|i|}|i�d|i|<|i�|i�q!W|i�dS(s+action taken upon link being closed by peerR¡RnN(sEOFN( tEOFhookR=R4R~R R3R¢RR6(RtkeyR¥((s#/usr/lib64/python2.6/idlelib/rpc.pyR¡Îs






cCsdS(sBClasses using rpc client/server can override to augment EOF actionN((R((s#/usr/lib64/python2.6/idlelib/rpc.pyR¦ÛsN("R+R,R�R RR5R6R=R@RBR`RcReRaRdRbRlRoRvRkRxRwRfRhR�R�R�R�R�R�R�R}R¡R¦(((s#/usr/lib64/python2.6/idlelib/rpc.pyR-|s>      *  

  
         I
RQcBseZRS((R+R,(((s#/usr/lib64/python2.6/idlelib/rpc.pyRQáscCs t|�}|t|<t|�S(N(tidR1Ry(RZR>((s#/usr/lib64/python2.6/idlelib/rpc.pyRRås 
RycBseZd�ZRS(cCs
||_dS(N(R>(RR>((s#/usr/lib64/python2.6/idlelib/rpc.pyRìs(R+R,R(((s#/usr/lib64/python2.6/idlelib/rpc.pyRyêsR
cBs/eZeZdZd�Zd�Zd�ZRS(s#ScCs6||_ti||�tii||||�dS(N(tcurrent_handlerR-RRtBaseRequestHandler(RR0Rtsvr((s#/usr/lib64/python2.6/idlelib/rpc.pyRôs cCs|i�dS(s(handle() method required by SocketServerN(Rv(R((s#/usr/lib64/python2.6/idlelib/rpc.pythandleùscCs
t||�S(N(Rz(RR>((s#/usr/lib64/python2.6/idlelib/rpc.pytget_remote_proxyýs(R+R,tFalseR/R8RR¬R­(((s#/usr/lib64/python2.6/idlelib/rpc.pyR
ïs
  t RPCClientcBsAeZeZdZdZeieid�Z d�Z
d�Z RS(s#CicCs9ti||�|_|ii|�|iid�dS(Ni(Rtlistening_socktbindtlisten(Rtaddresstfamilyttype((s#/usr/lib64/python2.6/idlelib/rpc.pyRscCs{|ii�\}}|iotidI|IJn|dtjoti||�ntidI|IJti �dS(Ns****** Connection request from is** Invalid host: (
R°tacceptR/RRt LOCALHOSTR-RRRU(Rt working_sockR³((s#/usr/lib64/python2.6/idlelib/rpc.pyR¶ s
cCs
t||�S(N(Rz(RR>((s#/usr/lib64/python2.6/idlelib/rpc.pyR­s( R+R,R®R/R8R�RtAF_INETt SOCK_STREAMRR¶R­(((s#/usr/lib64/python2.6/idlelib/rpc.pyR¯s 
RzcBs8eZdZdZd�Zd�Zd�Zd�ZRS(cCs||_||_dS(N(tsockioR>(RR»R>((s#/usr/lib64/python2.6/idlelib/rpc.pyRs cCs¬|idjo|i�n|ii|�ot|i|i|�S|idjo|i�n|ii |�o&|ii
|id|fh�}|St |�dS(Nt__getattribute__( t_RPCProxy__methodsR t_RPCProxy__getmethodsR�t MethodProxyR»R>t_RPCProxy__attributest_RPCProxy__getattributesRLRcR�(Rtnametvalue((s#/usr/lib64/python2.6/idlelib/rpc.pyt __getattr__"scCs%|ii|iddh�|_dS(NRF((R»RcR>RÀ(R((s#/usr/lib64/python2.6/idlelib/rpc.pyt__getattributes0scCs%|ii|iddh�|_dS(NRD((R»RcR>R½(R((s#/usr/lib64/python2.6/idlelib/rpc.pyt __getmethods4sN( R+R,R R½RÀRRÄRÁR¾(((s#/usr/lib64/python2.6/idlelib/rpc.pyRzs    cCsªx>t|�D]0}t||�}t|�od||<q
q
Wt|�tijot|i|�nt|�tijo%x"|i D]}t||�q�WndS(Ni(
tdirRPtcallableRµRt InstanceTypeRMt __class__t ClassTypet __bases__(RZR[RÂtattrtsuper((s#/usr/lib64/python2.6/idlelib/rpc.pyRM8s


cCsEx>t|�D]0}t||�}t|�pd||<q
q
WdS(Ni(RÇRPRÈ(RZR\RÂRÍ((s#/usr/lib64/python2.6/idlelib/rpc.pyRNEs


R¿cBseZd�Zd�ZRS(cCs||_||_||_dS(N(R»R>RÂ(RR»R>RÂ((s#/usr/lib64/python2.6/idlelib/rpc.pyRMs  cOs%|ii|i|i||�}|S(N(R»RcR>RÂ(RR:RYRÃ((s#/usr/lib64/python2.6/idlelib/rpc.pyt__call__Rs!(R+R,RRÏ(((s#/usr/lib64/python2.6/idlelib/rpc.pyR¿Ks (%t__doc__RR%RR�RR�tcPickleR�RR�R#tcopy_regRRRR
RR�R·RR R1RSR�R?R-RQRRRyRªR
R¯RzRMRNR¿(((s#/usr/lib64/python2.6/idlelib/rpc.pyt<module>sB              

2ÿf