;ò
�ü?c           @   sÓ  d  Z  d k Z d k Z d k Z d k Z d k Z d k Z d k Z d k	 Z	 d k
 Z
 d k Z d k Z d k Z d k Z d „  Z d „  Z e i e i e e ƒ d d Z d Z d e i f d „  ƒ  YZ h  Z e
 i
 d	 ƒ Z e
 i
 d	 ƒ Z d
 f  d „  ƒ  YZ d f  d „  ƒ  YZ d „  Z d f  d „  ƒ  YZ d e i e f d „  ƒ  YZ d e f d „  ƒ  YZ d f  d „  ƒ  YZ  d „  Z! d „  Z" d f  d „  ƒ  YZ# d „  Z$ d „  Z% d „  Z& e' d j o e& ƒ  n d S(   s  RPC 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.

Nc         C   s1   t  i |  ƒ } t | t i ƒ p t ‚ | Sd  S(   N(   s   marshals   loadss   mss   cos
   isinstances   typess   CodeTypes   AssertionError(   s   mss   co(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   unpickle_code-   s    c         C   s:   t  |  t i ƒ p t ‚ t i |  ƒ } t | f f Sd  S(   N(	   s
   isinstances   cos   typess   CodeTypes   AssertionErrors   marshals   dumpss   mss   unpickle_code(   s   cos   ms(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   pickle_code2   s    i   i   s	   127.0.0.1s	   RPCServerc           B   s8   t  Z e d „ Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s1   | t j o
 t } n t i i |  | | ƒ d  S(   N(   s   handlerclasss   Nones
   RPCHandlers   SocketServers	   TCPServers   __init__s   selfs   addr(   s   selfs   addrs   handlerclass(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__G   s    
c         C   s   d S(   s@   Override TCPServer method, no bind() phase for connecting entityN(    (   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   server_bindL   s     c         C   s   |  i i |  i ƒ d S(   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(   s   selfs   sockets   connects   server_address(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   server_activateP   s     c         C   s   |  i |  i f Sd S(   s:   Override TCPServer method, return already connected socketN(   s   selfs   sockets   server_address(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   get_requestY   s     c         C   sÄ   y ‚  Wn¶ t  j
 o
 ‚  n¢ t i } | d d d IJ| d IJ| d t i ƒ  i ƒ  IJ| d I| IJ| d It | ƒ IJt
 i d | ƒ | d	 IJ| d d IJt i d
 ƒ n Xd 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   
s   -i(   s   Unhandled server exception!s
   Thread: %ss   Client Address: s	   Request: s   files#   
*** Unrecoverable, server exiting!i    N(   s
   SystemExits   syss
   __stderr__s   erfs	   threadings   currentThreads   getNames   client_addresss   reprs   requests	   tracebacks	   print_excs   oss   _exit(   s   selfs   requests   client_addresss   erf(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   handle_error]   s      	

(   s   __name__s
   __module__s   Nones   __init__s   server_binds   server_activates   get_requests   handle_error(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys	   RPCServerE   s
   				i    s   SocketIOc           B   s"  t  Z d Z e e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z d Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" RS(    Ni    c         C   sh   t  i ƒ  |  _ | t j	 o | |  _ n | |  _ | t j o
 t } n | |  _ h  |  _	 h  |  _
 d  S(   N(   s	   threadings   currentThreads   selfs
   sockthreads	   debuggings   Nones   socks   objtables   objecttables	   responsess   cvars(   s   selfs   socks   objtables	   debugging(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__€   s    	
		c         C   s1   |  i } t |  _ | t j	 o | i ƒ  n d  S(   N(   s   selfs   socks   Nones   close(   s   selfs   sock(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   close‹   s    		c         C   s   t  i ƒ  d S(   s!   override for specific exit actionN(   s   oss   _exit(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   exithook‘   s     c         G   sl   |  i o d  Sn |  i d t t i ƒ  i ƒ  ƒ } x" | D] } | d t | ƒ } q= Wt
 i | IJd  S(   Ns    (   s   selfs	   debuggings   locations   strs	   threadings   currentThreads   getNames   ss   argss   as   syss
   __stderr__(   s   selfs   argss   as   s(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   debug•   s    # c         C   s   | |  i | <d  S(   N(   s   objects   selfs   objtables   oid(   s   selfs   oids   object(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   register�   s    c         C   s(   y |  i | =Wn t j
 o n Xd  S(   N(   s   selfs   objtables   oids   KeyError(   s   selfs   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   unregister    s    c         C   s  |  i d | ƒ y | \ } \ } }
 }	 } Wn t j
 o d d f Sn X|  i	 i
 | ƒ o d d | f Sn |  i	 | } |
 d j o! h  } t | | ƒ d | f Sn |
 d j o! h  } t | | ƒ d | f Sn t | |
 ƒ o d d |
 f Sn t | |
 ƒ } y“ | d	 j o= | |	 | Ž  } t | t ƒ o t | ƒ } n d | f SnF | d
 j o* t i | | |	 | f f ƒ d t f Sn d d | f SWn^ t j
 o
 ‚  nJ t i j
 o
 ‚  n2 |  i d ƒ t i d t  i! ƒ d t f Sn Xd  S(   Ns
   localcall:s   ERRORs   Bad request formats   Unknown object id: %ss   __methods__s   OKs   __attributes__s   Unsupported method name: %ss   CALLs   QUEUEs   QUEUEDs   Unsupported message type: %ss   localcall:EXCEPTIONs   files	   EXCEPTION("   s   selfs   debugs   requests   hows   oids
   methodnames   argss   kwargss	   TypeErrors   objtables   has_keys   objs   methodss   _getmethodss
   attributess   _getattributess   hasattrs   getattrs   methods   rets
   isinstances   RemoteObjects	   remoterefs   request_queues   puts   seqs   Nones
   SystemExits   sockets   errors	   tracebacks	   print_excs   syss
   __stderr__(   s   selfs   seqs   requests   methodss   rets   hows   kwargss   methods   oids   argss
   methodnames   objs
   attributes(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys	   localcall¦   sJ    c         C   s<   |  i d | | ƒ |  i | | | | ƒ } |  i | ƒ Sd  S(   Ns   remotecall:asynccall: (	   s   selfs   debugs   oids
   methodnames	   asynccalls   argss   kwargss   seqs   asyncreturn(   s   selfs   oids
   methodnames   argss   kwargss   seq(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   remotecallÎ   s    c         C   s<   |  i d | | ƒ |  i | | | | ƒ } |  i | ƒ Sd  S(   Ns   remotequeue:asyncqueue: (	   s   selfs   debugs   oids
   methodnames
   asyncqueues   argss   kwargss   seqs   asyncreturn(   s   selfs   oids
   methodnames   argss   kwargss   seq(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   remotequeueÓ   s    c         C   s�   d | | | | f f } |  i ƒ  } t i	 ƒ  |  i
 j o t i ƒ  } | |  i | <n |  i d | | | | | ƒ |  i | | f ƒ | Sd  S(   Ns   CALLs   asynccall:%d:(   s   oids
   methodnames   argss   kwargss   requests   selfs   newseqs   seqs	   threadings   currentThreads
   sockthreads	   Conditions   cvars   cvarss   debugs
   putmessage(   s   selfs   oids
   methodnames   argss   kwargss   cvars   seqs   request(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys	   asynccallØ   s    c         C   s�   d | | | | f f } |  i ƒ  } t i	 ƒ  |  i
 j o t i ƒ  } | |  i | <n |  i d | | | | | ƒ |  i | | f ƒ | Sd  S(   Ns   QUEUEs   asyncqueue:%d:(   s   oids
   methodnames   argss   kwargss   requests   selfs   newseqs   seqs	   threadings   currentThreads
   sockthreads	   Conditions   cvars   cvarss   debugs
   putmessage(   s   selfs   oids
   methodnames   argss   kwargss   cvars   seqs   request(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   asyncqueueâ   s    c         C   sK   |  i d | ƒ |  i | d d ƒ} |  i d | | ƒ |  i | ƒ Sd  S(   Ns#   asyncreturn:%d:call getresponse(): s   waitf0.050000000000000003s   asyncreturn:%d:response: (   s   selfs   debugs   seqs   getresponses   responses   decoderesponse(   s   selfs   seqs   response(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   asyncreturnì   s    c         C   sÁ   | \ } } | d j o | Sn | d j o t Sn | d j o |  i d ƒ t Sn | d j o |  i d ƒ |  i ƒ  t Sn | d j o |  i d | ƒ t | ‚ n t | | f ‚ d  S(	   Ns   OKs   QUEUEDs	   EXCEPTIONs   decoderesponse: EXCEPTIONs   EOFs   decoderesponse: EOFs   ERRORs   decoderesponse: Internal ERROR:(	   s   responses   hows   whats   Nones   selfs   debugs   decode_interrupthooks   RuntimeErrors   SystemError(   s   selfs   responses   whats   how(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   decoderesponseò   s     
c         C   s
   t  ‚ d S(   s    N(   s   EOFError(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   decode_interrupthook  s     c         C   sE   y |  i d t d d ƒ Wn$ t j
 o |  i d ƒ d Sn Xd S(   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.

        s   myseqs   waitf0.050000000000000003s   mainloop:returnN(   s   selfs   getresponses   Nones   EOFErrors   debug(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   mainloop  s     c         C   s]   |  i | | ƒ } | t j	 o6 | \ } } | d j o | |  i | ƒ f } qU n | Sd  S(   Ns   OK(	   s   selfs   _getresponses   myseqs   waits   responses   Nones   hows   whats   _proxify(   s   selfs   myseqs   waits   whats   hows   response(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   getresponse  s    c         C   sS   t  | t ƒ o t |  | i ƒ Sn t  | t i ƒ o t |  i	 | ƒ Sn | Sd  S(   N(
   s
   isinstances   objs   RemoteProxys   RPCProxys   selfs   oids   typess   ListTypes   maps   _proxify(   s   selfs   obj(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _proxify  s
    c         C   sç   |  i d | ƒ t i ƒ  |  i j o: xº n o+ |  i | | ƒ } | t	 j	 o | Sq) q0 Wn„ |  i
 | } | i ƒ  x# |  i i | ƒ o | i ƒ  qz W|  i | } |  i d | | f ƒ |  i | =|  i
 | =| i ƒ  | Sd  S(   Ns   _getresponse:myseq:i   s-   _getresponse:%s: thread woke up: response: %s(   s   selfs   debugs   myseqs	   threadings   currentThreads
   sockthreads   pollresponses   waits   responses   Nones   cvarss   cvars   acquires	   responsess   has_keys   release(   s   selfs   myseqs   waits   cvars   response(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _getresponse%  s$     
 


c         C   s   |  i d |  _ } | Sd  S(   Ni   (   s   selfs   nextseqs   seq(   s   selfs   seq(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   newseq;  s    c         C   sØ   |  i d | d ƒ y t i | ƒ } Wn- t i j
 o t i d I| IJ‚  n Xt	 i
 d t | ƒ ƒ | } x] t | ƒ d j oI y |  i i | ƒ } Wn" t t i f j
 o t ‚ qw X| | } qw Wd  S(   Ns   putmessage:%d:i    s   Cannot pickle:s   <i(   s   selfs   debugs   messages   pickles   dumpss   ss   UnpicklingErrors   syss
   __stderr__s   structs   packs   lens   socks   sends   ns   AttributeErrors   sockets   errors   IOError(   s   selfs   messages   ns   s(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   putmessage?  s     c         C   s;   t  i  |  i i ƒ  g g  g  | ƒ \ } } } t | ƒ Sd  S(   N(	   s   selects   selfs   socks   filenos   waits   rs   ws   xs   len(   s   selfs   waits   rs   ws   x(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   ioreadyP  s    -s    i   c         C   s¹   |  i ƒ  t |  i ƒ |  i j  oˆ |  i | ƒ o t Sn y |  i i	 t
 ƒ } Wn t i j
 o t ‚ n Xt | ƒ d j o
 t ‚ n |  i | 7_ |  i ƒ  n |  i ƒ  Sd  S(   Ni    (   s   selfs   _stage0s   lens   buffers   bufneeds   ioreadys   waits   Nones   socks   recvs   BUFSIZEs   ss   sockets   errors   EOFErrors   _stage1(   s   selfs   waits   s(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   pollpacketX  s    

c         C   sm   |  i d j o t |  i ƒ d j oC |  i d  } |  i d |  _ t i d | ƒ d |  _ d |  _ n d  S(   Ni    i   s   <ii   (   s   selfs   bufstates   lens   buffers   ss   structs   unpacks   bufneed(   s   selfs   s(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _stage0g  s
    &c         C   sj   |  i d j o t |  i ƒ |  i j o= |  i |  i  } |  i |  i |  _ d |  _ d |  _ | Sn d  S(   Ni   i   i    (   s   selfs   bufstates   lens   buffers   bufneeds   packet(   s   selfs   packet(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _stage1n  s    )		c         C   s�   |  i | ƒ } | t j o t Sn y t i | ƒ } WnK t i	 d IJt i	 d I| IJt
 i d t i	 ƒ t i	 d IJ‚  n X| Sd  S(   Ns   -----------------------s   cannot unpickle packet:s   file(   s   selfs
   pollpackets   waits   packets   Nones   pickles   loadss   messages   syss
   __stderr__s	   tracebacks   print_stack(   s   selfs   waits   packets   message(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   pollmessagev  s    c   
      C   së  xän oÜy t  i d ƒ } Wn t i j
 o n- X| \ } }	 | d |	 f f } |  i	 | ƒ y( |  i
 | ƒ } | t j o t Sn Wn7 t j
 o |  i ƒ  t Sn t j
 o t Sn X| \ } } | d } |  i d | | f ƒ | d d f j ov |  i d | ƒ |  i | | ƒ }	 |  i d | |	 f ƒ | d j o |  i	 | |	 f ƒ q | d j o q q
 q | | j o | Sq |  i i | t ƒ } | t j	 o/ | i ƒ  | |  i | <| i ƒ  | i ƒ  q q
 q
 Wd	 S(
   sR  Handle 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.

        i   i    s   OKs   pollresponse:%d:myseq:%ss   CALLs   QUEUEs   pollresponse:%d:localcall:call:s%   pollresponse:%d:localcall:response:%sN(   s   response_queues   gets   qmsgs   Queues   Emptys   seqs   responses   messages   selfs
   putmessages   pollmessages   waits   Nones   EOFErrors
   handle_EOFs   AttributeErrors   resqs   hows   debugs   myseqs	   localcalls   cvarss   cvs   acquires	   responsess   notifys   release(
   s   selfs   myseqs   waits   seqs   resqs   cvs   hows   qmsgs   messages   response(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   pollresponse„  sP      
	


c         C   sw   |  i ƒ  |  i d ƒ xO |  i D]D } |  i | } | i ƒ  d t f |  i | <| i	 ƒ  | i
 ƒ  q! W|  i ƒ  d S(   s+   action taken upon link being closed by peers
   handle_EOFs   EOFN(   s   selfs   EOFhooks   debugs   cvarss   keys   cvs   acquires   Nones	   responsess   notifys   releases   exithook(   s   selfs   cvs   key(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   handle_EOFÍ  s     

 

c         C   s   d S(   sB   Classes using rpc client/server can override to augment EOF actionN(    (   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   EOFhookÚ  s     (#   s   __name__s
   __module__s   nextseqs   Nones   __init__s   closes   exithooks   debugs   registers
   unregisters	   localcalls
   remotecalls   remotequeues	   asynccalls
   asyncqueues   asyncreturns   decoderesponses   decode_interrupthooks   mainloops   getresponses   _proxifys   _getresponses   newseqs
   putmessages   ioreadys   buffers   bufneeds   bufstates
   pollpackets   _stage0s   _stage1s   pollmessages   pollresponses
   handle_EOFs   EOFhook(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   SocketIO|   s@   						(			
	
															I	s   RemoteObjectc           B   s   t  Z RS(   N(   s   __name__s
   __module__(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   RemoteObjectà  s   c         C   s$   t  |  ƒ } |  t | <t | ƒ Sd  S(   N(   s   ids   objs   oids   objecttables   RemoteProxy(   s   objs   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys	   remoterefä  s    
s   RemoteProxyc           B   s   t  Z d „  Z RS(   Nc         C   s   | |  _  d  S(   N(   s   oids   self(   s   selfs   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__ë  s    (   s   __name__s
   __module__s   __init__(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   RemoteProxyé  s   s
   RPCHandlerc           B   s/   t  Z e Z d Z d „  Z d „  Z d „  Z RS(   Ns   #Sc         C   s6   |  | _ t i |  | ƒ t i i |  | | | ƒ d  S(   N(	   s   selfs   svrs   current_handlers   SocketIOs   __init__s   socks   SocketServers   BaseRequestHandlers   addr(   s   selfs   socks   addrs   svr(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__ó  s    	c         C   s   |  i ƒ  d S(   s(   handle() method required by SocketServerN(   s   selfs   mainloop(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   handleø  s     c         C   s   t  |  | ƒ Sd  S(   N(   s   RPCProxys   selfs   oid(   s   selfs   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   get_remote_proxyü  s    (   s   __name__s
   __module__s   Falses	   debuggings   locations   __init__s   handles   get_remote_proxy(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   RPCHandlerî  s
   		s	   RPCClientc           B   sA   t  Z e Z d Z d Z e i e i d „ Z	 d „  Z
 d „  Z RS(   Ns   #Ci   c         C   sU   t  i  | | ƒ |  _ |  i i t  i t  i d ƒ |  i i | ƒ |  i i
 d ƒ d  S(   Ni   (   s   sockets   familys   types   selfs   listening_socks
   setsockopts
   SOL_SOCKETs   SO_REUSEADDRs   binds   addresss   listen(   s   selfs   addresss   familys   type(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__  s
    c         C   s{   |  i i ƒ  \ } } |  i o t i d I| IJn | d t j o t	 i
 |  | ƒ n t i d I| IJt i ‚ d  S(   Ns   ****** Connection request from i    s   ** Invalid host: (   s   selfs   listening_socks   accepts   working_socks   addresss	   debuggings   syss
   __stderr__s	   LOCALHOSTs   SocketIOs   __init__s   sockets   error(   s   selfs   working_socks   address(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   accept  s    
c         C   s   t  |  | ƒ Sd  S(   N(   s   RPCProxys   selfs   oid(   s   selfs   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   get_remote_proxy  s    (   s   __name__s
   __module__s   Falses	   debuggings   locations   nextseqs   sockets   AF_INETs   SOCK_STREAMs   __init__s   accepts   get_remote_proxy(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys	   RPCClientÿ  s   	
s   RPCProxyc           B   s8   t  Z e Z e Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  | |  _ d  S(   N(   s   sockios   selfs   oid(   s   selfs   sockios   oid(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__  s    	c         C   sŽ   |  i t j o |  i ƒ  n |  i i | ƒ o t |  i |  i | ƒ Sn |  i	 t j o |  i
 ƒ  n |  i	 i | ƒ o t | ‚ n d  S(   N(   s   selfs   _RPCProxy__methodss   Nones   _RPCProxy__getmethodss   gets   names   MethodProxys   sockios   oids   _RPCProxy__attributess   _RPCProxy__getattributess   has_keys   AttributeError(   s   selfs   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __getattr__#  s    c         C   s%   |  i i |  i d f  h  ƒ |  _ d  S(   Ns   __attributes__(   s   selfs   sockios
   remotecalls   oids   _RPCProxy__attributes(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __getattributes-  s    c         C   s%   |  i i |  i d f  h  ƒ |  _ d  S(   Ns   __methods__(   s   selfs   sockios
   remotecalls   oids   _RPCProxy__methods(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __getmethods1  s    (	   s   __name__s
   __module__s   Nones   _RPCProxy__methodss   _RPCProxy__attributess   __init__s   __getattr__s   _RPCProxy__getattributess   _RPCProxy__getmethods(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   RPCProxy  s   		
	c         C   sª   x> t  |  ƒ D]0 } t |  | ƒ } t | ƒ o d | | <q q Wt |  ƒ t i	 j o t
 |  i | ƒ n t |  ƒ t i j o% x" |  i D] } t
 | | ƒ q‹ Wn d  S(   Ni   (   s   dirs   objs   names   getattrs   attrs   callables   methodss   types   typess   InstanceTypes   _getmethodss	   __class__s	   ClassTypes	   __bases__s   super(   s   objs   methodss   attrs   supers   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _getmethods5  s     
 c         C   sF   x? t  |  ƒ D]1 } t |  | ƒ } t | ƒ o d | | <q q Wd  S(   Ni   (   s   dirs   objs   names   getattrs   attrs   callables
   attributes(   s   objs
   attributess   names   attr(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   _getattributesB  s
     s   MethodProxyc           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  | |  _ | |  _ d  S(   N(   s   sockios   selfs   oids   name(   s   selfs   sockios   oids   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__J  s    		c         O   s)   |  i i |  i |  i | | ƒ } | Sd  S(   N(   s   selfs   sockios
   remotecalls   oids   names   argss   kwargss   value(   s   selfs   argss   kwargss   value(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __call__O  s    !(   s   __name__s
   __module__s   __init__s   __call__(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   MethodProxyH  s   	c         C   sR   d f  d „  ƒ  Y} | d ƒ } t |  ƒ } | i d | ƒ | | _ | i ƒ  d  S(   Ns   RemotePersonc           B   s,   t  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  d  S(   N(   s   names   self(   s   selfs   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__Z  s    c         C   s   d GHd | |  i  f GHHd  S(   Ns   (someone called greet)s   Hello %s, I am %s.(   s   names   self(   s   selfs   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   greet\  s    c         C   s   d GHH|  i Sd  S(   Ns   (someone called getName)(   s   selfs   name(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   getName`  s    c         C   s:   d GHd | GH|  i i i | ƒ } | i d ƒ d GHHd  S(   Ns   (someone called greet_this_guy)s   About to greet %s ...s   Thomas Edisons   Done.(   s   names   selfs   servers   current_handlers   get_remote_proxys
   remote_guys   greet(   s   selfs   names
   remote_guy(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   greet_this_guyd  s    	(   s   __name__s
   __module__s   __init__s   greets   getNames   greet_this_guy(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   RemotePersonY  s   			s   Thomas Edisons   thomas(   s   RemotePersons   persons	   RPCServers   addrs   svrs   registers   servers   handle_request(   s   addrs   persons   svrs   RemotePerson(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   testServerW  s    	c         C   s§   d k  } t |  ƒ } | i d ƒ } d GH| i ƒ  GHH| i d ƒ d GH| i d ƒ d GHH| i d ƒ d	 f  d
 „  ƒ  Y} | d ƒ } | i d | ƒ | i d ƒ d S(   s   demonstrates RPC ClientNs   thomass   The remote person's name is ...i   s"   Getting remote thomas to say hi...s   Alexander Bells   Done.i   s   LocalPersonc           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  d  S(   N(   s   names   self(   s   selfs   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   __init__‡  s    c         C   s	   d GHd  S(   Ns   You've greeted me!(    (   s   selfs   name(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   greet‰  s    c         C   s   |  i Sd  S(   N(   s   selfs   name(   s   self(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   getName‹  s    (   s   __name__s
   __module__s   __init__s   greets   getName(    (    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   LocalPerson†  s   		s	   alexander(   s   times	   RPCClients   addrs   clts   get_remote_proxys   thomass   getNames   sleeps   greets   LocalPersons   persons   registers   greet_this_guy(   s   addrs   thomass   LocalPersons   persons   times   clt(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys
   testClientt  s"     	c          C   sZ   t  d f }  t t i ƒ d j o* t i d d j o t |  ƒ d  SqL n t |  ƒ d  S(   Ni�"  i   i   s   -server(   s	   LOCALHOSTs   addrs   lens   syss   argvs
   testServers
   testClient(   s   addr(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   test’  s    
s   __main__((   s   __doc__s   syss   oss   sockets   selects   SocketServers   structs   cPickles   pickles	   threadings   Queues	   tracebacks   copy_regs   typess   marshals   unpickle_codes   pickle_codes   CodeTypes   BUFSIZEs	   LOCALHOSTs	   TCPServers	   RPCServers   objecttables   request_queues   response_queues   SocketIOs   RemoteObjects	   remoterefs   RemoteProxys   BaseRequestHandlers
   RPCHandlers	   RPCClients   RPCProxys   _getmethodss   _getattributess   MethodProxys
   testServers
   testClients   tests   __name__("   s   copy_regs   oss   SocketIOs   RemoteObjects   RPCProxys   objecttables
   testClients   selects   pickle_codes
   RPCHandlers   request_queues	   LOCALHOSTs   tests	   RPCClients   unpickle_codes   SocketServers   Queues   MethodProxys   _getattributess   _getmethodss   response_queues   typess   structs   syss	   remoterefs   sockets
   testServers	   RPCServers	   tracebacks   RemoteProxys	   threadings   BUFSIZEs   pickles   marshal(    (    s(   /mit/python/lib/python2.3/idlelib/rpc.pys   ?   sL   															
2ÿ e						