<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , print_function <EOL> import click <EOL> from sentry . runner . decorators import configuration <EOL> @ click . group ( ) <EOL> def queues ( ) : <EOL> "<STR_LIT>" <EOL> @ queues . command ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = False , is_flag = True , help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = False , is_flag = True , help = '<STR_LIT>' ) <EOL> @ configuration <EOL> def list ( sort_size , reverse ) : <EOL> "<STR_LIT>" <EOL> from django . conf import settings <EOL> from sentry . monitoring . queues import backend <EOL> if backend is None : <EOL> raise click . ClickException ( '<STR_LIT>' ) <EOL> queues = backend . bulk_get_sizes ( [ q . name for q in settings . CELERY_QUEUES ] ) <EOL> if sort_size : <EOL> queues = sorted ( queues , key = lambda q : ( - q [ <NUM_LIT:1> ] , q [ <NUM_LIT:0> ] ) , reverse = reverse ) <EOL> else : <EOL> queues = sorted ( queues , reverse = reverse ) <EOL> for queue in queues : <EOL> click . echo ( '<STR_LIT>' % queue ) <EOL> @ queues . command ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = False , is_flag = True , help = '<STR_LIT>' ) <EOL> @ click . argument ( '<STR_LIT>' ) <EOL> @ configuration <EOL> def purge ( force , queue ) : <EOL> "<STR_LIT>" <EOL> from sentry . monitoring . queues import get_queue_by_name , backend <EOL> if get_queue_by_name ( queue ) is None : <EOL> raise click . ClickException ( '<STR_LIT>' % queue ) <EOL> if backend is None : <EOL> raise click . ClickException ( '<STR_LIT>' ) <EOL> size = backend . get_size ( queue ) <EOL> if size == <NUM_LIT:0> : <EOL> click . echo ( '<STR_LIT>' , err = True ) <EOL> return <EOL> if not force : <EOL> click . confirm ( '<STR_LIT>' % ( size , queue ) , abort = True ) <EOL> click . echo ( '<STR_LIT>' % backend . purge_queue ( queue ) , err = True ) </s>
