<s> import logging <EOL> import sys <EOL> from tornado . ioloop import IOLoop <EOL> from stormed import Connection , Message <EOL> severities = sys . argv [ <NUM_LIT:1> : ] <EOL> if not severities : <EOL> print >> sys . stderr , "<STR_LIT>" % sys . argv [ <NUM_LIT:0> ] <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> ch = None <EOL> def on_connect ( ) : <EOL> global ch <EOL> ch = conn . channel ( ) <EOL> ch . exchange_declare ( exchange = '<STR_LIT>' , type = '<STR_LIT>' ) <EOL> ch . queue_declare ( exclusive = True , callback = with_temp_queue ) <EOL> def with_temp_queue ( qinfo ) : <EOL> for severity in severities : <EOL> ch . queue_bind ( exchange = '<STR_LIT>' , <EOL> queue = qinfo . queue , <EOL> routing_key = severity ) <EOL> ch . consume ( qinfo . queue , callback , no_ack = True ) <EOL> def callback ( msg ) : <EOL> print "<STR_LIT>" % ( msg . rx_data . routing_key , msg . body ) <EOL> logging . basicConfig ( ) <EOL> conn = Connection ( host = '<STR_LIT:localhost>' ) <EOL> conn . connect ( on_connect ) <EOL> io_loop = IOLoop . instance ( ) <EOL> print '<STR_LIT>' <EOL> try : <EOL> io_loop . start ( ) <EOL> except KeyboardInterrupt : <EOL> conn . close ( io_loop . stop ) </s>
