<s> '''<STR_LIT>''' <EOL> import salt . crypt <EOL> import zmq <EOL> class AlertClient ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , opts ) : <EOL> self . opts = opts <EOL> self . auth = salt . crypt . SAuth ( opts ) <EOL> self . socket = self . __get_socket ( ) <EOL> def __get_socket ( self ) : <EOL> '''<STR_LIT>''' <EOL> context = zmq . Context ( ) <EOL> socket = context . socket ( zmq . REQ ) <EOL> socket . connect ( self . opts [ '<STR_LIT>' ] ) <EOL> return socket <EOL> def alert ( self , host , severity , category , msg ) : <EOL> '''<STR_LIT>''' <EOL> load = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:host>' : host , <EOL> '<STR_LIT>' : severity . lower ( ) , <EOL> '<STR_LIT>' : severity . upper ( ) , <EOL> '<STR_LIT>' : category , <EOL> '<STR_LIT>' : msg } <EOL> payload = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . auth . crypticle . dumps ( load ) } <EOL> self . socket . send_pyobj ( payload ) <EOL> return self . auth . crypticle . loads ( self . socket . recv_pyobj ( ) ) </s>
