Your IP : 18.117.93.183


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/run.cpython-34.pyc

�
e fi5�@sddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZddl	mZdd	l	mZddlZd
ZddlZdddd�Zdad
d�Zed�ej�Zedd�Zdadadaddd�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd �Z$Gd!d"�d"ej%�Z&Gd#d$�d$ej'�Z(Gd%d&�d&e)�Z*ed�dS)'�N)�CallTips)�AutoComplete)�RemoteDebugger)�RemoteObjectBrowser)�StackViewer)�rpc)�PyShell)�	IOBindingz	127.0.0.1c
CsW|dkrtj}ny&|jtj|||||��Wntk
rRYnXdS)zuShow Idle-format warning after replacing warnings.showwarning.

    The only difference is the formatter called.
    N)�sys�stderr�writerZidle_formatwarning�IOError)�message�category�filename�lineno�file�line�r�0/opt/alt/python34/lib64/python3.4/idlelib/run.py�idle_showwarning_subprocs
rcCsL|r*tdkrHtjatt_qHntdk	rHtt_dandS)zFReplace warning.showwarning with idle_showwarning_subproc, or reverse.N)�_warnings_showwarning�warnings�showwarningr)Zcapturerrr�capture_warnings*s		rTcCs|jd�dS)z�Process any tk events that are ready to be dispatched if tkinter
    has been imported, a tcl interpreter has been created and tk has been
    loaded.�updateN)�eval)�tclrrr�handle_tk_events:srFcCs|ay2ttj�dks$t�ttjd�}Wntddtj�dSYnXtd�dgtjdd�<t	j
dtdd	d
t|ff�}d|_
|j�xby�tr�yt�Wq�tk
r�w�Yq�Xny%tjjdddd
�\}}Wntjk
r,t�w�YnX|\}}}|||�}tjj||f�Wq�tk
r�tr�danw�Yq�tk
r�td��Yq�tj�\}	}
}y!t�tjj|df�Wn+tj|	|
|dtj�t�YnXw�Yq�Xq�WdS)ajStart the Python execution server in a subprocess

    In the Python subprocess, RPCServer is instantiated with handlerclass
    MyHandler, which inherits register/unregister methods from RPCHandler via
    the mix-in class SocketIO.

    When the RPCServer 'server' is instantiated, the TCPServer initialization
    creates an instance of run.MyHandler and calls its handle() method.
    handle() instantiates a run.Executive object, passing it a reference to the
    MyHandler object.  That reference is saved as attribute rpchandler of the
    Executive instance.  The Executive methods have access to the reference and
    can pass it on to entities that they command
    (e.g. RemoteDebugger.Debugger.start_debugger()).  The latter, in turn, can
    call MyHandler(SocketIO) register/unregister methods via the reference to
    register and unregister themselves.

    �z/IDLE Subprocess: no IP port passed in sys.argv.rNT��target�nameZ
SockThread�args�blockZtimeoutg�������?F���)�no_exitfunc�lenr
�argv�AssertionError�int�print�
__stderr__r�	threadingZThread�
manage_socket�	LOCALHOSTZdaemon�start�exit_now�exit�KeyboardInterruptrZ
request_queue�get�queueZEmptyrZresponse_queueZput�quitting�
SystemExit�exc_info�print_exception�	traceback)Zdel_exitfuncZportZ
sockthread�seq�request�methodr#�kwargsZret�type�value�tbrrr�mainHs\	
	
	

%
	

rBcCs�x�td�D]w}tj|�yt|t�}PWq
tk
r�}z-td|jdddtj	�|}WYdd}~Xq
Xq
Wtddtj	�t
||�dadS|j�dS)N�zIDLE Subprocess: OSError: rz, retrying....rz8IDLE Subprocess: Connection to IDLE GUI failed, exiting.T)
�range�time�sleep�MyRPCServer�	MyHandler�OSErrorr+r#r
r,�show_socket_errorr1Zhandle_request)�address�iZserver�errZsocket_errorrrrr.�s
	

r.cCs�ddl}ddlj}|j�}|j�|jddkrgd|}|jd|d|�n!|jdd|jdd|�|j�dS)Nr�=z�IDLE's subprocess can't connect to %s:%d.  This may be due to your personal firewall configuration.  It is safe to allow this internal connection because no data is visible on external ports.zIDLE Subprocess Error�parentzSocket Error: %sr)�tkinterZtkinter.messageboxZ
messageboxZTkZwithdrawr#Z	showerrorZdestroy)rMrKrPZtkMessageBox�root�msgrrrrJ�s
	rJcs�ddl}|j�t�tj�tj�\}}}}|\t_t_t_t	�����fdd���|||�dS)Nrc	s<�j|�|j}|j}|dk	rc|�krc�t|�||j�tdd��nN|dk	r�|jr�|�kr��t|�||j�tdd��n|r�tj|�}tdd��d
}t	||�tj
|d��ntj||�}x$|D]}t|ddd��qWdS)NzF
The above exception was the direct cause of the following exception:
rzE
During handling of the above exception, another exception occurred:
z"Traceback (most recent call last):�run.py�rpc.py�threading.py�queue.py�RemoteDebugger.py�bdb.py�endr )rSrTrUrVrWrX)�add�__context__�	__cause__r?�
__traceback__r+�__suppress_context__r:�
extract_tb�cleanup_traceback�
print_list�format_exception_only)	�typ�excrA�context�causeZtbe�exclude�linesr)�efile�	print_exc�seenrrrj�s.
			

	


z"print_exception.<locals>.print_exc)
�	linecache�
checkcache�flush_stdoutr
rr8�	last_type�
last_value�last_traceback�set)rlrc�valrAZexcinfor)rirjrkrr9�s
		r9c
Cs}|dd�}x>|rPx*|D]!}|ddj|�r Pq q WP|d=qWx>|r�x*|D]!}|ddj|�raPqaqaWP|d
=qTWt|�dkr�|dd�|dd�<tddtj�ntjdj}x�tt|��D]~}||\}}}}	|dkr(d}n|	r_|j	d	�r_|j
d
d||fi�}	n||||	f||<q�WdS)zARemove excluded traces from beginning/end of tb; get cached linesNrrz** IDLE Internal Exception: r�exec�?z
-toplevel-z	<pyshell#rl�getliner%r%)�countr'r+r
rrZobjecttable�
rpchandlerrD�
startswithZ
remotecall)
rArgZorig_tbZrpcfilerxrL�fn�lnZnmrrrrr`�s2	
	
	r`cCsdS)zXXX How to do this now?Nrrrrrrn�srncCs:trddl}|j�ntd�tjd�dS)z�Exit subprocess, possibly after first clearing exit functions.

    If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
    functions registered with atexit will be removed before exiting.
    (VPython support)

    rNF)r&�atexitZ_clearrr
r2)r|rrrr2�s


r2c@seZdZdd�ZdS)rGcCs	y�Wn�tk
r�Yn�tk
r?datj�Yn�tj}tdddd|�tdd|�tdtj	�j
d|�td|d|�td	t|�d|�tj
d|�td
d|�tddd|�datj�YnXdS)zrOverride RPCServer method for IDLE

        Interrupt the MainThread and exit server if link is dropped.

        T�
�-�(rzUnhandled server exception!z
Thread: %szClient Address: z	Request: z#
*** Unrecoverable, server exiting!N)r7�EOFErrorr1�thread�interrupt_mainr
r,r+r-Zcurrent_threadr"�reprr:rjr6)�selfr<Zclient_addressZerfrrr�handle_error
s&

	zMyRPCServer.handle_errorN)�__name__�
__module__�__qualname__r�rrrrrGsrGc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rHcCs�t|�}|jd|�|jd�|_tj|jdtj�t_	tj
|jdtj�t_tj
|jdtj�t_t
jt_ddl}|j|_tj	|_|jd�|_t
jj|d	dd
d�dS)zOverride base methodrt�console�stdin�stdoutrrN�interpZmyseq�waitg�������?)�	Executive�register�get_remote_proxyr�rZPseudoInputFiler	�encodingr
r�ZPseudoOutputFiler�rr�displayhook�pydocZ
plainpagerZpagerZ_keep_stdinr��
RPCHandlerZgetresponse)r�Z	executiver�rrr�handle(szMyHandler.handlecCstjd�dS)z>override SocketIO method - wait for MainThread to shut us down�
N)rErF)r�rrr�exithook@szMyHandler.exithookcCsdatj�dS)zEOverride SocketIO method - terminate wait on callback and exit threadTN)r6r�r�)r�rrr�EOFhookDszMyHandler.EOFhookcCsdatj�dS)zinterrupt awakened threadTN)r6r�r�)r�rrr�decode_interrupthookJszMyHandler.decode_interrupthookN)r�r�r�r�r�r�r�rrrrrH&srHc@sseZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dS)r�cCs7||_tj|_tj�|_tj�|_dS)N)rx�__main__�__dict__�localsr�calltipr�autocomplete)r�rxrrr�__init__Ss	zExecutive.__init__cCs�y1d|_dazt||j�WddaXWnmtk
rEYnctj�|_trgt�nt	�|j
jjd�}|r�|j
j
j�nYnXt�dS)NTFz<<toggle-jit-stack-viewer>>)�usr_exc_info�
interruptablertr�r7r
r8r6r2r9rxr�Zgetvarr�Zopen_remote_stack_viewerrn)r��codeZjitrrr�runcodeYs"	

zExecutive.runcodecCstrtj�ndS)N)r�r�r�)r�rrr�interrupt_the_serverrszExecutive.interrupt_the_servercCstj|j|�S)N)rZstart_debuggerrx)r�Zgui_adap_oidrrr�start_the_debuggervszExecutive.start_the_debuggercCs|jj|�dS)zDUnregister the Idb Adapter.  Link objects and Idb then subject to GCN)rxZ
unregister)r�Zidb_adap_oidrrr�stop_the_debuggeryszExecutive.stop_the_debuggercCs|jj|�S)N)r�Z	fetch_tip)r�r"rrr�get_the_calltip}szExecutive.get_the_calltipcCs|jj||�S)N)r�Zfetch_completions)r�Zwhat�moderrr�get_the_completion_list�sz!Executive.get_the_completion_listNcCs�|jr|j\}}}ndSd}|dk	rI|jj|�}nx)|rt|jjddkrt|j}qLW|t_|t_t	j
||�}tj|�S)Nr�r�run)zrpcr�)
r�rxr��tb_frame�	f_globals�tb_nextr
rorprZ
StackTreeItemrZremote_object_tree_item)r�Z	flist_oidrcrsrAZflist�itemrrr�stackviewer�s	
		zExecutive.stackviewer)r�r�r�r�r�r�r�r�r�r�r�rrrrr�Qsr�)+r
rlrEr:�_threadr�r-r5rPZidlelibrrrrrrrr	r�r/rrrrZTclrrr1r6r�rBr.rJr9r`rnr2Z	RPCServerrGr�rH�objectr�rrrr�<module>sL


I$+A

?>