def pop(queue, quantity=1):
 cmd = 'SELECT name FROM {0}'.format(queue)
 if (quantity != 'all'):
  try:
   quantity = int(quantity)
  except ValueError as exc:
   error_txt = 'Quantity must be an integer or "all".\nError: "{0}".'.format(exc)
   raise SaltInvocationError(error_txt)
  cmd = ''.join([cmd, ' LIMIT {0}'.format(quantity)])
 log.debug('SQL Query: {0}'.format(cmd))
 con = _conn(queue)
 items = []
 with con:
  cur = con.cursor()
  result = cur.execute(cmd).fetchall()
  if (len(result) > 0):
   items = [item[0] for item in result]
   itemlist = '","'.join(items)
   _quote_escape(itemlist)
   del_cmd = 'DELETE FROM {0} WHERE name IN ("{1}")'.format(queue, itemlist)
   log.debug('SQL Query: {0}'.format(del_cmd))
   cur.execute(del_cmd)
  con.commit()
 log.info(items)
 return items

def pop ( queue , quantity = 1 ) : cmd = 'SELECT name FROM {0}' . format ( queue ) if ( quantity != 'all' ) : try : quantity = int ( quantity ) except ValueError as exc : error_txt = 'Quantity must be an integer or "all".\nError: "{0}".' . format ( exc ) raise SaltInvocationError ( error_txt ) cmd = '' . join ( [ cmd , ' LIMIT {0}' . format ( quantity ) ] ) log . debug ( 'SQL Query: {0}' . format ( cmd ) ) con = _conn ( queue ) items = [ ] with con : cur = con . cursor ( ) result = cur . execute ( cmd ) . fetchall ( ) if ( len ( result ) > 0 ) : items = [ item [ 0 ] for item in result ] itemlist = '","' . join ( items ) _quote_escape ( itemlist ) del_cmd = 'DELETE FROM {0} WHERE name IN ("{1}")' . format ( queue , itemlist ) log . debug ( 'SQL Query: {0}' . format ( del_cmd ) ) cur . execute ( del_cmd ) con . commit ( ) log . info ( items ) return items
pop one or more or all items from the queue return them .