2013-09-11 19:58:58 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-09-11 19:58:58 +02:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
2013-09-11 19:58:58 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.core.management import CommandError
|
|
|
|
from zerver.lib.queue import SimpleQueueClient
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (ArgumentParser) -> None
|
2015-08-21 02:10:41 +02:00
|
|
|
parser.add_argument('queue_name', metavar='<queue name>', type=str,
|
|
|
|
help="queue to purge")
|
|
|
|
|
2013-09-11 19:58:58 +02:00
|
|
|
help = "Discards all messages from the given queue"
|
2016-11-29 07:22:02 +01:00
|
|
|
|
2013-09-11 19:58:58 +02:00
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **str) -> None
|
2015-08-21 02:10:41 +02:00
|
|
|
queue_name = options['queue_name']
|
2013-09-11 19:58:58 +02:00
|
|
|
queue = SimpleQueueClient()
|
2013-10-23 18:02:42 +02:00
|
|
|
queue.ensure_queue(queue_name, lambda: None)
|
|
|
|
queue.channel.queue_purge(queue_name)
|
2015-11-01 17:11:06 +01:00
|
|
|
print("Done")
|