Files
zulip/zerver/management/commands/purge_queue.py
Tim Abbott 68dcc760c3 Clean up some unused imports.
(imported from commit 0c5d8e2a55ba1b8909ba807fee3afe863dcdc226)
2013-11-04 11:51:17 -05:00

19 lines
611 B
Python

from __future__ import absolute_import
from django.core.management.base import BaseCommand
from django.core.management import CommandError
from zerver.lib.queue import SimpleQueueClient
class Command(BaseCommand):
args = "<queue name>"
help = "Discards all messages from the given queue"
def handle(self, *args, **options):
if len(args) != 1:
raise CommandError("Wrong number of arguments")
queue_name = args[0]
queue = SimpleQueueClient()
queue.ensure_queue(queue_name, lambda: None)
queue.channel.queue_purge(queue_name)
print "Done"