Viewing File: /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/run.cpython-35.pyc



Yf-6@s2ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZddl	m
Z
ddl	mZddl	mZddl	mZdd	l	mZddlZx)d/D]!Zeeeejde=qWdZddlZddddZdaddZedejZeddZdadada dddZ!ddZ"dd Z#d!d"Z$d#d$Z%d%d&Z&d'd(Z'Gd)d*d*ej(Z)Gd+d,d,ej*Z+Gd-d.d.e,Z-eddS)0N)CallTips)AutoComplete)RemoteDebugger)RemoteObjectBrowser)StackViewer)rpc)PyShell)	IOBindingsimpledialog
messageboxfontdialog
filedialogcommondialogcolorchooserztkinter.z	127.0.0.1c
CsT|dkrtj}y&|jtj|||||Wntk
rOYnXdS)zuShow Idle-format warning after replacing warnings.showwarning.

    The only difference is the formatter called.
    N)sysstderrwriterZidle_formatwarningIOError)messagecategoryfilenamelinenofileliner0/opt/alt/python35/lib64/python3.5/idlelib/run.pyidle_showwarning_subproc s	
rcCsF|r'tdkrBtjatt_ntdk	rBtt_dadS)zFReplace warning.showwarning with idle_showwarning_subproc, or reverse.N)_warnings_showwarningwarningsshowwarningr)Zcapturerrrcapture_warnings0s		r!TcCs|jddS)zProcess 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)tclrrrhandle_tk_events@sr%FcCs|ay2ttjdks$tttjd}WntddtjdSYnXtddgtjdd<t	j
dtdd	d
t|ff}d|_
|jx\ytrytWntk
rwYnXy%tjjdddd
\}}Wntjk
r)twYnX|\}}}|||}tjj||fWqtk
rtr{dawYqtk
rtdYqtj\}	}
}y!ttjj|dfWn+tj|	|
|dtjtYnXwYqXqWdS)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.rNTtargetnameZ
SockThreadargsblockZtimeoutg?F)no_exitfunclenrargvAssertionErrorintprint
__stderr__r!	threadingZThread
manage_socket	LOCALHOSTZdaemonstartexit_nowexitKeyboardInterruptrZ
request_queuegetqueueZEmptyr%Zresponse_queueZputquitting
SystemExitexc_infoprint_exception	traceback)Zdel_exitfuncZportZ
sockthreadseqrequestmethodr*kwargsZrettypevaluetbrrrmainNs\	
	
	

%


rIcCsxtdD]w}tj|yt|t}PWq
tk
r}z-td|jdddtj	|}WYdd}~Xq
Xq
Wtddtj	t
||dadS|jdS)NzIDLE Subprocess: OSError: r&z, retrying....rz8IDLE Subprocess: Connection to IDLE GUI failed, exiting.T)
rangetimesleepMyRPCServer	MyHandlerOSErrorr2r*rr3show_socket_errorr8Zhandle_request)addressiZservererrZsocket_errorrrrr5s
	

r5cCsddl}ddlj}|j}|j|jddkrgd|}|jd|d|n!|jdd|jdd||jdS)Nr=zIDLE'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 ErrorparentzSocket Error: %sr&)tkinterZtkinter.messageboxrZTkZwithdrawr*Z	showerrorZdestroy)rTrRrWZtkMessageBoxrootmsgrrrrQs
	rQcsddl}|jttjtj\}}}}|\t_t_t_t	fdd|||dS)Nrc	s6j||j}|j}|dk	rc|krct|||jtddnK|dk	r|jr|krt|||jtdd|rtj|}tddd
}t	||tj
|dtj||}x$|D]}t|dddqWdS)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.pyrpc.pythreading.pyqueue.pyRemoteDebugger.pybdb.pyendr')rZr[r\r]r^r_)add__context__	__cause__rF
__traceback__r2__suppress_context__rA
extract_tbcleanup_traceback
print_listformat_exception_only)	typexcrHcontextcauseZtbeexcludelinesr)efile	print_excseenrrrqs.
			

	

z"print_exception.<locals>.print_exc)
	linecache
checkcacheflush_stdoutrrr?	last_type
last_valuelast_tracebackset)rsrjvalrHZexcinfor)rprqrrrr@s
		r@c
Csn|dd}x;|rMx'|D]}|ddj|r Pq WP|d=qWx;|rx'|D]}|ddj|r^Pq^WP|d
=qQWt|dkr|dd|dd<tddtjtjdj}xtt|D]x}||\}}}}	|dkrd}|	rP|j	d	rP|j
d
d||fi}	||||	f||<qWdS)zARemove excluded traces from beginning/end of tb; get cached linesNrr&z** IDLE Internal Exception: rexec?z
-toplevel-z	<pyshell#rsgetliner,r,)countr.r2rrrZobjecttable
rpchandlerrK
startswithZ
remotecall)
rHrnZorig_tbZrpcfilerrSfnlnZnmrrrrrgs2	
	
rgcCsdS)zXXX How to do this now?NrrrrrrusrucCs7trddl}|jtdtjddS)zExit 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_clearr!rr9)rrrrr9s


r9c@seZdZddZdS)rNcCs	yWntk
rYntk
r?datjYntj}tdddd|tdd|tdtj	j
d|td|d|td	t|d|tj
d|td
d|tddd|datjYnXdS)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)r>EOFErrorr8threadinterrupt_mainrr3r2r4Zcurrent_threadr)reprrArqr=)selfrCZclient_addressZerfrrrhandle_errors&

	zMyRPCServer.handle_errorN)__name__
__module____qualname__rrrrrrNsrNc@s@eZdZddZddZddZddZd	S)
rOcCst|}|jd||jd|_tj|jdtjt_	tj
|jdtjt_tj
|jdtjt_t
jt_ddl}|j|_tj	|_|jd|_t
jj|d	dd
ddS)zOverride base methodr{consolestdinstdoutrrNinterpZmyseqwaitg?)	Executiveregisterget_remote_proxyrrZPseudoInputFiler	encodingrrZPseudoOutputFilerrrdisplayhookpydocZ
plainpagerZpagerZ_keep_stdinr
RPCHandlerZgetresponse)rZ	executiverrrrhandle.szMyHandler.handlecCstjddS)z>override SocketIO method - wait for MainThread to shut us down
N)rLrM)rrrrexithookFszMyHandler.exithookcCsdatjdS)zEOverride SocketIO method - terminate wait on callback and exit threadTN)r=rr)rrrrEOFhookJszMyHandler.EOFhookcCsdatjdS)zinterrupt awakened threadTN)r=rr)rrrrdecode_interrupthookPszMyHandler.decode_interrupthookN)rrrrrrrrrrrrO,srOc@sseZdZddZddZddZddZd	d
ZddZd
dZ	dddZ
dS)rcCs7||_tj|_tj|_tj|_dS)N)r__main____dict__localsrcalltiprautocomplete)rrrrr__init__Ys	zExecutive.__init__cCsy1d|_dazt||jWddaXWngtk
rEYn]tj|_trdtt	|j
jjd}|r|j
j
jYnXtdS)NTFz<<toggle-jit-stack-viewer>>)usr_exc_info
interruptabler{rr>rr?r=r9r@rrZgetvarrZopen_remote_stack_viewerru)rcodeZjitrrrruncode_s"	
zExecutive.runcodecCstrtjdS)N)rrr)rrrrinterrupt_the_serverxszExecutive.interrupt_the_servercCstj|j|S)N)rZstart_debuggerr)rZgui_adap_oidrrrstart_the_debugger|szExecutive.start_the_debuggercCs|jj|dS)zDUnregister the Idb Adapter.  Link objects and Idb then subject to GCN)rZ
unregister)rZidb_adap_oidrrrstop_the_debuggerszExecutive.stop_the_debuggercCs|jj|S)N)rZ	fetch_tip)rr)rrrget_the_calltipszExecutive.get_the_calltipcCs|jj||S)N)rZfetch_completions)rZwhatmoderrrget_the_completion_listsz!Executive.get_the_completion_listNcCs|jr|j\}}}ndSd}|dk	rF|jj|}x)|rq|jjddkrq|j}qIW|t_|t_t	j
||}tj|S)Nrrrun)rr)
rrrtb_frame	f_globalstb_nextrrvrwrZ
StackTreeItemrZremote_object_tree_item)rZ	flist_oidrjrzrHZflistitemrrrstackviewers	
		zExecutive.stackviewer)rrrrrrrrrrrrrrrrWsr)r
rrr
rrr).rrsrLrA_threadrr4r<rWZidlelibrrrrrrrr	rmoddelattrmodulesr6rrrr!ZTclr$r%r8r=rrIr5rQr@rgrur9Z	RPCServerrNrrOobjectrrrrr<module>sV




I$+A
Back to Directory File Manager