;
Ñâ"Ic               @   s¨  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 m
 Z
 d  d l	 m Z d  d l	 m Z d  d l	 m Z d  d l	 m Z d  d l	 m Z d  d l Z d Z y d  d l Z Wn e k
 o Yn Xd d d	 „ Z e e _ d a d a d a d d
 „ Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! Gd „  d e j" ƒ Z# Gd „  d e j$ ƒ Z% Gd „  d e& ƒ Z' d S(   i    N(   u   CallTips(   u   AutoComplete(   u   RemoteDebugger(   u   RemoteObjectBrowser(   u   StackViewer(   u   rpcu	   127.0.0.1c             C   sz   d } | d | | f 7} | d k o t j | | ƒ j ƒ  n | } | o | d | 7} n | d | j |  f 7} | S(   u   Format warnings the IDLE wayu!   
Warning (from warnings module):
u     File "%s", line %s
u       %s
u   %s: %s
N(   u   Noneu	   linecacheu   getlineu   stripu   __name__(   u   messageu   categoryu   filenameu   linenou   fileu   lineu   s(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   idle_formatwarning_subproc   s    ,c             C   sê  |  a  d } t j d d … o t t j d ƒ } n d g t j d d … <t j d t d d d t | f f ƒ } d | _	 | j
 ƒ  x\yª t o) y t ƒ  Wq½ t k
 o wŠ Yq½ Xn y% t j j d	 d d
 d ƒ \ } } Wn t j k
 o wŠ Yn X| \ } } } | | | Ž  } t j j | | f ƒ WqŠ t k
 o t o
 d a n wŠ YqŠ t k
 o ‚  YqŠ t j ƒ  \ }	 }
 } y! t ƒ  t j j | d f ƒ Wn+ t j |	 |
 | d t j ƒt ƒ  Yn XwŠ YqŠ XqŠ d S(   uj  Start 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.

    i"  i   Nu    u   targetu   nameu
   SockThreadu   argsu   blocku   timeoutgš™™™™™©?u   fileT(   u   no_exitfuncu   sysu   argvu   intu	   threadingu   Threadu   manage_socketu	   LOCALHOSTu   Trueu   daemonu   startu   exit_nowu   exitu   KeyboardInterruptu   rpcu   request_queueu   getu   queueu   Emptyu   response_queueu   putu   quittingu
   SystemExitu   exc_infou   print_exceptionu   Noneu	   tracebacku
   __stderr__(   u   del_exitfuncu   portu
   sockthreadu   sequ   requestu   methodu   argsu   kwargsu   retu   typeu   valueu   tb(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   main0   sN    	
%	
c             C   s¿   x® t  d ƒ D]v } t j | ƒ y t |  t ƒ } PWq t j k
 o= } z' t d | j d d d t	 j
 ƒWYd  d  } ~ Xq Xq Wt d d t	 j
 ƒt | |  ƒ d a d  S| j ƒ  d  S(   Ni   u   IDLE Subprocess: socket error: i   u   , retrying....u   fileu8   IDLE Subprocess: Connection to IDLE GUI failed, exiting.T(   u   rangeu   timeu   sleepu   MyRPCServeru	   MyHandleru   socketu   erroru   printu   argsu   sysu
   __stderr__u   show_socket_erroru   Trueu   exit_nowu   handle_request(   u   addressu   iu   serveru   err(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   manage_socketq   s     )	
c             C   s’   d d  l  } d d  l j } | j ƒ  } | j ƒ  |  j d d k o$ d | } | j d | d | ƒn | j d d |  j d ƒ | j ƒ  d  S(   Ni    i=   u¿   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.u   IDLE Subprocess Erroru   parentu   Socket Error: %si   (   u   tkinteru   tkinter.messageboxu
   messageboxu   Tku   withdrawu   argsu	   showerroru   destroy(   u   erru   addressu   tkinteru   tkMessageBoxu   rootu   msg(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   show_socket_errorƒ   s    
	c        
      C   sÙ   d d  l  }  |  j ƒ  t ƒ  t j } t j ƒ  \ } } } } | \ t _ t _ t _ t	 j
 | ƒ } t d d | ƒd } t | | ƒ t	 j | d | ƒt	 j | | ƒ } x$ | D] }	 t |	 d
 d d | ƒqµ Wd  S(   Ni    u"   Traceback (most recent call last):u   fileu   run.pyu   rpc.pyu   threading.pyu   queue.pyu   RemoteDebugger.pyu   bdb.pyu   endu    (   u   run.pyu   rpc.pyu   threading.pyu   queue.pyu   RemoteDebugger.pyu   bdb.py(   u	   linecacheu
   checkcacheu   flush_stdoutu   sysu   stderru   exc_infou	   last_typeu
   last_valueu   last_tracebacku	   tracebacku
   extract_tbu   printu   cleanup_tracebacku
   print_listu   format_exception_only(
   u	   linecacheu   efileu   typu   valu   tbu   excinfou   tbeu   excludeu   linesu   line(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   print_exception“   s     
	  c       
      C   sŒ  |  d d … } xB |  o: x, | D]# } |  d d j  | ƒ o Pq! q! WP|  d =q WxB |  o: x, | D]# } |  d d j  | ƒ o Pqf qf WP|  d =qX Wt |  ƒ d k o1 | d d … |  d d … <t d d t j ƒn t j d j } x— t t |  ƒ ƒ D]ƒ } |  | \ } } } }	 | d k o
 d } n |	 o2 | j	 d	 ƒ o" | j
 d
 d | | f i  ƒ }	 n | | | |	 f |  | <qWd S(   uA   Remove excluded traces from beginning/end of tb; get cached linesNi    iÿÿÿÿu   ** IDLE Internal Exception: u   fileu   execu   ?u
   -toplevel-u	   <pyshell#u	   linecacheu   getline(   u   countu   lenu   printu   sysu   stderru   rpcu   objecttableu
   rpchandleru   rangeu
   startswithu
   remotecall(
   u   tbu   excludeu   orig_tbu   rpcfileu
   rpchandleru   iu   fnu   lnu   nmu   line(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   cleanup_traceback¤   s<      	  	 
c               C   s   d S(   u   XXX How to do this now?N(    (    (    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   flush_stdoutÃ   s    c              C   s2   t  o d d l }  |  j ƒ  n t j d ƒ d S(   uê   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)

    i    N(   u   no_exitfuncu   atexitu   _clearu   sysu   exit(   u   atexit(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   exitÆ   s    c             B   s   |  Ee  Z d  „  Z d S(   c             C   s  y ‚  Wnt  k
 o ‚  Yní t k
 o d a t j ƒ  YnÊ t j } t d d d d | ƒt d d | ƒt d t	 j
 ƒ  j ƒ  d | ƒt d | d | ƒt d t | ƒ d | ƒt j d | ƒ t d	 d | ƒt d d d | ƒd a t j ƒ  Yn Xd
 S(   ur   Override RPCServer method for IDLE

        Interrupt the MainThread and exit server if link is dropped.

        u   
u   -i(   u   fileu   Unhandled server exception!u
   Thread: %su   Client Address: u	   Request: u#   
*** Unrecoverable, server exiting!NT(   u
   SystemExitu   EOFErroru   Trueu   exit_nowu   threadu   interrupt_mainu   sysu
   __stderr__u   printu	   threadingu   current_threadu   get_nameu   repru	   tracebacku	   print_excu   quitting(   u   selfu   requestu   client_addressu   erf(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   handle_errorÕ   s&    	 N(   u   __name__u
   __module__u   handle_error(   u
   __locals__(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   MyRPCServerÓ   s   
u   MyRPCServerc             B   s2   |  Ee  Z d  „  Z d „  Z d „  Z d „  Z d S(   c             C   sÖ   t  |  ƒ } |  j d | ƒ |  j d ƒ t _ |  _ |  j d ƒ t _ |  j d ƒ t _ d d l } | j	 | _
 d d l m } | j t j _ t j _ t j _ |  j d ƒ |  _ t j j |  d	 d d
 d ƒd S(   u   Override base methodu   execu   stdinu   stdoutu   stderri    N(   u	   IOBindingu   interpu   mysequ   waitgš™™™™™©?(   u	   Executiveu   registeru   get_remote_proxyu   sysu   stdinu   consoleu   stdoutu   stderru   pydocu
   plainpageru   pageru   idlelibu	   IOBindingu   encodingu   interpu   rpcu
   RPCHandleru   getresponseu   None(   u   selfu	   executiveu   pydocu	   IOBinding(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   handleô   s    #c             C   s   t  j d ƒ d S(   u>   override SocketIO method - wait for MainThread to shut us downi
   N(   u   timeu   sleep(   u   self(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   exithook  s    c             C   s   d a t j ƒ  d S(   uE   Override SocketIO method - terminate wait on callback and exit threadNT(   u   Trueu   quittingu   threadu   interrupt_main(   u   self(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   EOFhook  s    c             C   s   d a t j ƒ  d S(   u   interrupt awakened threadNT(   u   Trueu   quittingu   threadu   interrupt_main(   u   self(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   decode_interrupthook  s    N(   u   __name__u
   __module__u   handleu   exithooku   EOFhooku   decode_interrupthook(   u
   __locals__(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu	   MyHandlerò   s   
			u	   MyHandlerc             B   sY   |  Ee  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z
 d S(	   c             C   s7   | |  _  t j |  _ t j ƒ  |  _ t j ƒ  |  _ d  S(   N(   u
   rpchandleru   __main__u   __dict__u   localsu   CallTipsu   calltipu   AutoCompleteu   autocomplete(   u   selfu
   rpchandler(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   __init__  s    	c             C   sŸ   y1 d  |  _ d a z t | |  j ƒ Wd  d a XWn` t j ƒ  |  _ t	 o t
 ƒ  n t ƒ  |  j j j d ƒ } | o |  j j j ƒ  n Yn Xt ƒ  d  S(   Nu   <<toggle-jit-stack-viewer>>TF(   u   Noneu   usr_exc_infou   Trueu   interruptableu   execu   localsu   Falseu   sysu   exc_infou   quittingu   exitu   print_exceptionu
   rpchandleru   consoleu   getvaru   interpu   open_remote_stack_vieweru   flush_stdout(   u   selfu   codeu   jit(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   runcode  s    	c             C   s   t  o t j ƒ  n d  S(   N(   u   interruptableu   threadu   interrupt_main(   u   self(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   interrupt_the_server2  s    c             C   s   t  j |  j | ƒ S(   N(   u   RemoteDebuggeru   start_debuggeru
   rpchandler(   u   selfu   gui_adap_oid(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   start_the_debugger6  s    c             C   s   |  j  j | ƒ d S(   uD   Unregister the Idb Adapter.  Link objects and Idb then subject to GCN(   u
   rpchandleru
   unregister(   u   selfu   idb_adap_oid(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   stop_the_debugger9  s    c             C   s   |  j  j | ƒ S(   N(   u   calltipu	   fetch_tip(   u   selfu   name(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   get_the_calltip=  s    c             C   s   |  j  j | | ƒ S(   N(   u   autocompleteu   fetch_completions(   u   selfu   whatu   mode(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   get_the_completion_list@  s    c             C   s­   |  j  o |  j  \ } } } n d  Sd  } | d  k	 o |  j j | ƒ } n x, | o$ | j j d d k o | j } qP W| t _ | t _	 t
 j | | ƒ } t j | ƒ S(   Nu   __name__u   rpcu   run(   u   rpcu   run(   u   usr_exc_infou   Noneu
   rpchandleru   get_remote_proxyu   tb_frameu	   f_globalsu   tb_nextu   sysu	   last_typeu
   last_valueu   StackVieweru   StackTreeItemu   RemoteObjectBrowseru   remote_object_tree_item(   u   selfu	   flist_oidu   typu   valu   tbu   flistu   item(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   stackviewerC  s    
 		N(   u   __name__u
   __module__u   __init__u   runcodeu   interrupt_the_serveru   start_the_debuggeru   stop_the_debuggeru   get_the_calltipu   get_the_completion_listu   Noneu   stackviewer(   u
   __locals__(    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu	   Executive  s   
							u	   ExecutiveF((   u   sysu	   linecacheu   timeu   socketu	   tracebacku   _threadu   threadu	   threadingu   queueu   idlelibu   CallTipsu   AutoCompleteu   RemoteDebuggeru   RemoteObjectBrowseru   StackVieweru   rpcu   __main__u	   LOCALHOSTu   warningsu   ImportErroru   Noneu   idle_formatwarning_subprocu   formatwarningu   Falseu   exit_nowu   quittingu   interruptableu   mainu   manage_socketu   show_socket_erroru   print_exceptionu   cleanup_tracebacku   flush_stdoutu   exitu	   RPCServeru   MyRPCServeru
   RPCHandleru	   MyHandleru   objectu	   Executive(    (    (    u(   /mit/python/lib/python3.0/idlelib/run.pyu   <module>   sD   
	A						#