<s> """<STR_LIT>""" <EOL> import sys <EOL> from pprint import pprint <EOL> try : <EOL> import zmq <EOL> except ImportError : <EOL> sys . stderr . write ( "<STR_LIT>" ) <EOL> raise <EOL> class SubClient ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , sub_addr = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . context = zmq . Context ( ) <EOL> self . sub_addr = sub_addr <EOL> self . sub_sock = self . context . socket ( zmq . SUB ) <EOL> self . sub_sock . connect ( self . sub_addr ) <EOL> print "<STR_LIT>" . format ( self . sub_addr ) <EOL> def print_msgs ( self ) : <EOL> """<STR_LIT>""" <EOL> print "<STR_LIT>" <EOL> while True : <EOL> try : <EOL> pprint ( self . sub_sock . recv ( ) ) <EOL> except KeyboardInterrupt : <EOL> print <EOL> return <EOL> def add_topic ( self , topic ) : <EOL> """<STR_LIT>""" <EOL> self . sub_sock . setsockopt ( zmq . SUBSCRIBE , topic ) <EOL> def del_topic ( self , topic ) : <EOL> """<STR_LIT>""" <EOL> self . sub_sock . setsockopt ( zmq . UNSUBSCRIBE , topic ) <EOL> def clean_up ( self ) : <EOL> """<STR_LIT>""" <EOL> self . sub_sock . close ( ) <EOL> self . context . term ( ) </s>
