AlkantarClanX12

Your IP : 18.117.188.105


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/idlelib/__pycache__/rpc.cpython-35.opt-2.pyc



���]0Q�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZdd�Zdd�Zddd�ZGdd	�d	ej�Zd
dZdZGd
d�dej�ZiZe	jd�Ze	jd�ZGdd�de�ZGdd�de�Zdd�ZGdd�de�Z Gdd�dej!e�Z"Gdd�de�Z#Gdd�de�Z$dd�Z%dd �Z&Gd!d"�d"e�Z'd#d$�Z(dS)%�NcCstj|�}|S)N)�marshal�loads)�ms�co�r�(/opt/alt/python35/lib64/python3.5/rpc.py�
unpickle_code/srcCstj|�}t|ffS)N)r�dumpsr)rrrrr�pickle_code4sr
cCs2tj�}t||�}|j|�|j�S)N)�io�BytesIO�CodePickler�dump�getvalue)�obj�protocol�f�prrrr	9s
r	c@s/eZdZejeiZejej�dS)r
N)	�__name__�
__module__�__qualname__�types�CodeTyper
�dispatch_table�update�copyregrrrrr
?sr
�iz	127.0.0.1c@sOeZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�	RPCServerNcCs,|dkrt}tjj|||�dS)N)�
RPCHandler�socketserver�	TCPServer�__init__)�self�addrZhandlerclassrrrr!HszRPCServer.__init__cCsdS)Nr)r"rrr�server_bindMszRPCServer.server_bindcCs|jj|j�dS)N)�socket�connect�server_address)r"rrr�server_activateQszRPCServer.server_activatecCs|j|jfS)N)r%r')r"rrr�get_requestZszRPCServer.get_requestcCs�y�Wn�tk
r�Yn�tj}tdddd|�tdd|�tdtj�jd|�td|d|�tdt|�d|�tj	d|�td	d|�tddd|�t
jd
�YnXdS)N�
�-�(�filezUnhandled server exception!z
Thread: %szClient Address: z	Request: z#
*** Unrecoverable, server exiting!r)�
SystemExit�sys�
__stderr__�print�	threading�current_thread�name�repr�	traceback�	print_exc�os�_exit)r"�requestZclient_address�erfrrr�handle_error^s
	zRPCServer.handle_error)rrrr!r$r(r)r<rrrrrFs
	rc@sreZdZdZdddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+Zd,ZdZd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!dS);�SocketIOrNcCs^tj�|_|dk	r$||_||_|dkr?t}||_i|_i|_dS)N)	r2r3�
sockthread�	debugging�sock�objecttable�objtable�	responses�cvars)r"r@rBr?rrrr!�s				zSocketIO.__init__cCs,|j}d|_|dk	r(|j�dS)N)r@�close)r"r@rrrrE�s		zSocketIO.closecCstjd�dS)Nr)r8r9)r"rrr�exithook�szSocketIO.exithookcGsi|js
dS|jdttj�j�}x"|D]}|dt|�}q4Wt|dtj�dS)N� r-)	r?�location�strr2r3r4r1r/r0)r"�args�s�arrr�debug�s	 
zSocketIO.debugcCs||j|<dS)N)rB)r"�oid�objectrrr�register�szSocketIO.registercCs'y|j|=Wntk
r"YnXdS)N)rB�KeyError)r"rNrrr�
unregister�s
zSocketIO.unregistercCs'|jd|�y|\}\}}}}Wntk
rDdSYnX||jkredd|ffS|j|}|dkr�i}	t||	�d|	fS|dkr�i}
t||
�d|
fSt||�s�dd|ffSt||�}y~|d	kr6|||�}t|t�r,t	|�}d|fS|d
krbt
j||||ff�dSdd|fSWn�tk
r��Yn�t
k
r��Yn�tk
r��Ynstk
r�}
zd
|
fSWYdd}
~
XnEd}t||||fdtj�tjdtj�dSYnXdS)Nz
localcall:�ERROR�Bad request formatzUnknown object id: %r�__methods__�OK�__attributes__zUnsupported method name: %r�CALL�QUEUE�QUEUEDzUnsupported message type: %s�CALLEXCzU*** Internal Error: rpc.py:SocketIO.localcall()

 Object: %s 
 Method: %s 
 Args: %s
r-�	EXCEPTION)rSrT)rZN)r\N)rM�	TypeErrorrB�_getmethods�_getattributes�hasattr�getattr�
isinstance�RemoteObject�	remoteref�
request_queue�putr.�KeyboardInterrupt�OSError�	Exceptionr1r/r0r6r7)r"�seqr:�howrN�
methodnamerJ�kwargsr�methods�
attributes�method�ret�ex�msgrrr�	localcall�sT
	








 zSocketIO.localcallcCs8|jd||�|j||||�}|j|�S)Nzremotecall:asynccall: )rM�	asynccall�asyncreturn)r"rNrlrJrmrjrrr�
remotecall�szSocketIO.remotecallcCs8|jd||�|j||||�}|j|�S)Nzremotequeue:asyncqueue: )rM�
asyncqueuerv)r"rNrlrJrmrjrrr�remotequeue�szSocketIO.remotequeuecCs�d||||ff}|j�}tj�|jkrRtj�}||j|<|jd|||||�|j||f�|S)NrXz
asynccall:%d:)�newseqr2r3r>�	ConditionrDrM�
putmessage)r"rNrlrJrmr:rj�cvarrrrru�s
zSocketIO.asynccallcCs�d||||ff}|j�}tj�|jkrRtj�}||j|<|jd|||||�|j||f�|S)NrYzasyncqueue:%d:)rzr2r3r>r{rDrMr|)r"rNrlrJrmr:rjr}rrrrx�s
zSocketIO.asyncqueuecCsG|jd|�|j|dd�}|jd||�|j|�S)Nz#asyncreturn:%d:call getresponse(): �waitg�������?zasyncreturn:%d:response: )rM�getresponse�decoderesponse)r"rj�responserrrrv�szSocketIO.asyncreturncCs�|\}}|dkr|S|dkr,dS|dkrI|jd�dS|dkrp|jd�|j�dS|dkr�|jd|�t|��|d	kr�|jd
|�|�t||��dS)NrVrZr\zdecoderesponse: EXCEPTION�EOFzdecoderesponse: EOFrSzdecoderesponse: Internal ERROR:r[zdecoderesponse: Call Exception:)rM�decode_interrupthook�RuntimeError�SystemError)r"r�rk�whatrrrr��s&


zSocketIO.decoderesponsecCs
t�dS)N)�EOFError)r"rrrr�szSocketIO.decode_interrupthookcCsDy|jdddd�Wn#tk
r?|jd�dSYnXdS)N�myseqr~g�������?zmainloop:return)rr�rM)r"rrr�mainloops


zSocketIO.mainloopcCsO|j||�}|dk	rK|\}}|dkrK||j|�f}|S)NrV)�_getresponse�_proxify)r"r�r~r�rkr�rrrrszSocketIO.getresponsecCsHt|t�rt||j�St|t�rDtt|j|��S|S)N)rb�RemoteProxy�RPCProxyrN�list�mapr�)r"rrrrr�'s
zSocketIO._proxifycCs�|jd|�tj�|jkrQx�|j||�}|dk	r(|Sq(Wn}|j|}|j�x||jkr�|j�qkW|j|}|jd||f�|j|=|j|=|j	�|SdS)Nz_getresponse:myseq:z-_getresponse:%s: thread woke up: response: %s)
rMr2r3r>�pollresponserD�acquirerCr~�release)r"r�r~r�r}rrrr�/s"


	


zSocketIO._getresponsecCs|jd|_}|S)N�)�nextseq)r"rjrrrrzEszSocketIO.newseqcCs|jd|d�yt|�}Wn4tjk
r[tdt|�dtj��YnXtj	dt
|��|}x�t
|�dkryDtjg|jgg�\}}}|jj
|dt��}Wn$ttfk
r�td��YnX||d�}q{WdS)Nzputmessage:%d:rzCannot pickle:r-z<izsocket no longer exists)rMr	�pickle�
PicklingErrorr1r5r/r0�struct�pack�len�selectr@�send�BUFSIZE�AttributeErrorr]rh)r"�messagerK�r�w�x�nrrrr|Is$ zSocketIO.putmessage��cCs�|j�t|j�|jkr�tj|jj�ggg|�\}}}t|�dkredSy|jjt�}Wnt	k
r�t
�YnXt|�dkr�t
�|j|7_|j�|j�S)Nr)�_stage0r��buff�bufneedr�r@�fileno�recvr�rhr��_stage1)r"r~r�r�r�rKrrr�
pollpacket]s
-

zSocketIO.pollpacketcCss|jdkrot|j�dkro|jdd�}|jdd�|_tjd|�d|_d|_dS)Nrr�z<i�)�bufstater�r�r��unpackr�)r"rKrrrr�ms
$zSocketIO._stage0cCsp|jdkrlt|j�|jkrl|jd|j�}|j|jd�|_d|_d|_|SdS)Nr�r�r)r�r�r�r�)r"�packetrrrr�ts'		zSocketIO._stage1cCs�|j|�}|dkrdSytj|�}Wnmtjk
r�tddtj�tdt|�dtj�tj	dtj�tddtj��YnX|S)Nz-----------------------r-zcannot unpickle packet:)
r�r�r�UnpicklingErrorr1r/r0r5r6�print_stack)r"r~r�r�rrr�pollmessage|szSocketIO.pollmessagec
Cs�x�ytjd�}Wntjk
r-Yn,X|\}}|d|ff}|j|�y#|j|�}|dkr{dSWn5tk
r�|j�dSYntk
r�dSYnX|\}}|d}|j	d||f�|dkr[|j	d|�|j
||�}|j	d||f�|dkrI|j||f�q|dkrqq||krk|S|jj|d�}	|	dk	r|	j�||j
|<|	j�|	j�qqWdS)	NrrVzpollresponse:%d:myseq:%srXrYzpollresponse:%d:localcall:call:z%pollresponse:%d:localcall:response:%s)rXrY)�response_queue�get�queue�Emptyr|r�r��
handle_EOFr�rMrtrDr�rC�notifyr�)
r"r�r~Zqmsgrjr�r�Zresqrk�cvrrrr��sL



	
	



zSocketIO.pollresponsecCsq|j�|jd�xI|jD]>}|j|}|j�d|j|<|j�|j�q!W|j�dS)Nr�r�)r�N)�EOFhookrMrDr�rCr�r�rF)r"�keyr�rrrr��s





zSocketIO.handle_EOFcCsdS)Nr)r"rrrr��szSocketIO.EOFhook)"rrrr�r!rErFrMrPrRrtrwryrurxrvr�r�r�rr�r�rzr|r�r�r�r�r�r�r�r�r�r�rrrrr=}s>.


I
r=c@seZdZdS)rcN)rrrrrrrrc�srccCs t|�}|t|<t|�S)N)�idrAr�)rrNrrrrd�s
rdc@seZdZdd�ZdS)r�cCs
||_dS)N)rN)r"rNrrrr!�szRemoteProxy.__init__N)rrrr!rrrrr��sr�c@s@eZdZdZdZdd�Zdd�Zdd�Zd	S)
rFz#ScCs6||_tj||�tjj||||�dS)N)Zcurrent_handlerr=r!r�BaseRequestHandler)r"r@r#Zsvrrrrr!�s	zRPCHandler.__init__cCs|j�dS)N)r�)r"rrr�handle�szRPCHandler.handlecCs
t||�S)N)r�)r"rNrrr�get_remote_proxyszRPCHandler.get_remote_proxyN)rrrr?rHr!r�r�rrrrr�s
rc@sReZdZdZdZdZejejdd�Z	dd�Z
dd	�Zd
S)�	RPCClientFz#Cr�cCs9tj||�|_|jj|�|jjd�dS)Nr�)r%�listening_sock�bind�listen)r"�address�family�typerrrr!szRPCClient.__init__cCsw|jj�\}}|jr4td|dtj�|dtkrWtj||�ntd|dtj�t	�dS)Nz****** Connection request from r-rz** Invalid host: )
r��acceptr?r1r/r0�	LOCALHOSTr=r!rh)r"Zworking_sockr�rrrr�s	zRPCClient.acceptcCs
t||�S)N)r�)r"rNrrrr�szRPCClient.get_remote_proxyN)rrrr?rHr�r%�AF_INET�SOCK_STREAMr!r�r�rrrrr�s
r�c@sLeZdZdZdZdd�Zdd�Zdd�Zdd	�ZdS)
r�NcCs||_||_dS)N)�sockiorN)r"r�rNrrrr!#s	zRPCProxy.__init__cCs�|jdkr|j�|jj|�rAt|j|j|�S|jdkrZ|j�||jkr�|jj|jd|fi�}|St	|��dS)N�__getattribute__)
�_RPCProxy__methods�_RPCProxy__getmethodsr��MethodProxyr�rN�_RPCProxy__attributes�_RPCProxy__getattributesrwr�)r"r4�valuerrr�__getattr__'s

zRPCProxy.__getattr__cCs%|jj|jdfi�|_dS)NrW)r�rwrNr�)r"rrrZ__getattributes5szRPCProxy.__getattributescCs%|jj|jdfi�|_dS)NrU)r�rwrNr�)r"rrrZ__getmethods9szRPCProxy.__getmethods)	rrrr�r�r!r�r�r�rrrrr�sr�cCspx9t|�D]+}t||�}t|�r
d||<q
Wt|t�rlx|jD]}t||�qUWdS)Nr�)�dirra�callablerbr��	__bases__r^)rrnr4�attr�superrrrr^=sr^cCs@x9t|�D]+}t||�}t|�s
d||<q
WdS)Nr�)r�rar�)rror4r�rrrr_Hsr_c@s(eZdZdd�Zdd�ZdS)r�cCs||_||_||_dS)N)r�rNr4)r"r�rNr4rrrr!Ps		zMethodProxy.__init__cOs%|jj|j|j||�}|S)N)r�rwrNr4)r"rJrmr�rrr�__call__Us!zMethodProxy.__call__N)rrrr!r�rrrrr�Nsr�cCs�|dkrdSdt_t|�}ytjj|�WnLtk
r�d}|j|d�}|j|d�}tjj|�YnXtjjd�|t_dS)N�ascii�backslashreplace�strictr*)	�builtins�_r5r/�stdout�write�UnicodeEncodeError�encode�decode)r��text�encoding�bytesrrr�displayhook]s	
r�))r/r8rr%r�rr�r�r2r�r6rrrr�rr
r	�Picklerr
r�r�r rrA�Queuerer�rOr=rcrdr�r�rr�r�r^r_r�r�rrrr�<module>sH
2�j