<s> from optparse import OptionParser <EOL> from circuits . node import Node <EOL> from circuits import Component , Debugger , Event <EOL> __version__ = "<STR_LIT>" <EOL> USAGE = "<STR_LIT>" <EOL> VERSION = "<STR_LIT>" + __version__ <EOL> class increment ( Event ) : <EOL> def __init__ ( self , value ) : <EOL> Event . __init__ ( self , value ) <EOL> def parse_options ( ) : <EOL> parser = OptionParser ( usage = USAGE , version = VERSION ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> action = "<STR_LIT:store>" , type = "<STR_LIT:string>" , <EOL> default = "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> opts , args = parser . parse_args ( ) <EOL> return opts , args <EOL> class NodeClient ( Component ) : <EOL> def init ( self , args , opts ) : <EOL> if opts . debug : <EOL> Debugger ( ) . register ( self ) <EOL> if "<STR_LIT::>" in opts . bind : <EOL> address , port = opts . bind . split ( "<STR_LIT::>" ) <EOL> port = int ( port ) <EOL> else : <EOL> address , port = opts . bind , <NUM_LIT> <EOL> auto_remote_event = { <EOL> '<STR_LIT>' : '<STR_LIT:*>' <EOL> } <EOL> node = Node ( ) . register ( self ) <EOL> node . add ( <EOL> '<STR_LIT>' , address , port , auto_remote_event = auto_remote_event ) <EOL> def connected_to ( self , * args , ** kwargs ) : <EOL> i = <NUM_LIT:0> <EOL> while True : <EOL> print ( i ) <EOL> i = ( yield self . call ( increment ( i ) ) ) . value <EOL> def main ( ) : <EOL> opts , args = parse_options ( ) <EOL> NodeClient ( args , opts ) . run ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
