<s> def main ( ) : <EOL> import sys <EOL> if len ( sys . argv ) > <NUM_LIT:1> and sys . argv [ <NUM_LIT:1> ] == '<STR_LIT:test>' : <EOL> import doctest <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT:..>' ) <EOL> import zero <EOL> import zero . rpc <EOL> fails , tests = doctest . testmod ( zero ) <EOL> fails2 , tests2 = doctest . testmod ( zero . rpc ) <EOL> tests += tests2 <EOL> if fails + fails2 : <EOL> msg = '<STR_LIT>' <EOL> sys . exit ( msg % ( tests , fails + fails2 ) ) <EOL> print '<STR_LIT>' % tests <EOL> return <EOL> import json <EOL> from zero import Zero , ZeroSetup , zauto , UnsupportedZmqMethod <EOL> try : <EOL> setup , loop = ZeroSetup . argv ( ) <EOL> zero = Zero ( setup ) <EOL> for msg in zauto ( zero , loop , setup . args [ '<STR_LIT>' ] ) : <EOL> sys . stdout . write ( json . dumps ( msg ) + '<STR_LIT:\n>' ) <EOL> sys . stdout . flush ( ) <EOL> except UnsupportedZmqMethod , e : <EOL> args = e . args [ <NUM_LIT:2> ] <EOL> if args [ '<STR_LIT>' ] : <EOL> from zero . rpc import zrpc <EOL> with open ( args [ '<STR_LIT>' ] ) as fin : <EOL> config = json . load ( fin ) <EOL> if len ( args [ '<STR_LIT>' ] ) == <NUM_LIT:1> : <EOL> zero = zrpc ( config , args [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> setup = zero . setup <EOL> if args [ '<STR_LIT>' ] : <EOL> setup . debugging ( True ) <EOL> for msg in zero : <EOL> if setup . transmits : <EOL> zero ( msg ) <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' , args [ '<STR_LIT>' ] ) <EOL> else : <EOL> raise e <EOL> if setup . args [ '<STR_LIT>' ] : <EOL> raw_input ( '<STR_LIT>' ) <EOL> zero . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
