def listen(opts):
 event = salt.utils.event.get_event(opts['node'], sock_dir=opts['sock_dir'], transport=opts['transport'], opts=opts, listen=True)
 check_access_and_print_warning(opts['sock_dir'])
 print(event.puburi)
 jid_counter = 0
 found_minions = []
 while True:
  ret = event.get_event(full=True)
  if (ret is None):
   continue
  if opts['func_count']:
   data = ret.get('data', False)
   if data:
    if (('id' in six.iterkeys(data)) and (data.get('id', False) not in found_minions)):
     if (data['fun'] == opts['func_count']):
      jid_counter += 1
      found_minions.append(data['id'])
      print('Reply received from [{0}]. Total replies now: [{1}].'.format(ret['data']['id'], jid_counter))
     continue
  else:
   print('Event fired at {0}'.format(time.asctime()))
   print(('*' * 25))
   print('Tag: {0}'.format(ret['tag']))
   print('Data:')
   pprint.pprint(ret['data'])

def listen ( opts ) : event = salt . utils . event . get_event ( opts [ 'node' ] , sock_dir = opts [ 'sock_dir' ] , transport = opts [ 'transport' ] , opts = opts , listen = True ) check_access_and_print_warning ( opts [ 'sock_dir' ] ) print ( event . puburi ) jid_counter = 0 found_minions = [ ] while True : ret = event . get_event ( full = True ) if ( ret is None ) : continue if opts [ 'func_count' ] : data = ret . get ( 'data' , False ) if data : if ( ( 'id' in six . iterkeys ( data ) ) and ( data . get ( 'id' , False ) not in found_minions ) ) : if ( data [ 'fun' ] == opts [ 'func_count' ] ) : jid_counter += 1 found_minions . append ( data [ 'id' ] ) print ( 'Reply received from [{0}]. Total replies now: [{1}].' . format ( ret [ 'data' ] [ 'id' ] , jid_counter ) ) continue else : print ( 'Event fired at {0}' . format ( time . asctime ( ) ) ) print ( ( '*' * 25 ) ) print ( 'Tag: {0}' . format ( ret [ 'tag' ] ) ) print ( 'Data:' ) pprint . pprint ( ret [ 'data' ] )
creates a new thread listening to that port defaults to ipaddr=127 .