<s> """<STR_LIT>""" <EOL> class PeerObjectProxy ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name , conn ) : <EOL> self . _name = name <EOL> self . _conn = conn <EOL> def notify ( self , * args ) : <EOL> self . _conn . sendNotify ( self . _name , args ) <EOL> def __call__ ( self , * args ) : <EOL> evt = self . _conn . sendRequest ( self . _name , args ) <EOL> return evt . waitForResponse ( ) <EOL> def __getattr__ ( self , name ) : <EOL> return PeerObjectProxy ( self . _name + "<STR_LIT:.>" + name , self . _conn ) <EOL> class PeerProxy : <EOL> def __init__ ( self , connectionHandler ) : <EOL> self . _connectionHandler = connectionHandler <EOL> def __getattr__ ( self , name ) : <EOL> return PeerObjectProxy ( name , self . _connectionHandler ) <EOL> import re <EOL> class ServiceProxy ( PeerProxy ) : <EOL> def __init__ ( self , url , localService = None , messageDelimiter = "<STR_LIT>" ) : <EOL> m = re . match ( r"<STR_LIT>" , url ) <EOL> if m : <EOL> from jsonrpc . socketserver import SocketServiceHandler <EOL> import socket <EOL> from threading import Thread <EOL> ( host , port ) = m . groups ( ) <EOL> port = int ( port ) <EOL> s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> s . connect ( ( host , port ) ) <EOL> conn = SocketServiceHandler ( s , localService , messageDelimiter = messageDelimiter ) <EOL> PeerProxy . __init__ ( self , conn ) <EOL> t = Thread ( target = conn . receiveForever ) <EOL> t . setDaemon ( True ) <EOL> t . start ( ) <EOL> else : <EOL> from jsonrpc . http import HTTPClientConnectionHandler <EOL> conn = HTTPClientConnectionHandler ( url , localService , messageDelimiter = messageDelimiter ) <EOL> PeerProxy . __init__ ( self , conn ) </s>
