@@ -0,0 +1,1517 @@
+from __future__ import absolute_import%0A%0Afrom django.core.management.base import BaseCommand%0Afrom zerver.lib.queue import queue_json_publish%0A%0Aimport sys%0Aimport ujson%0A%0A%0Adef error(*args):%0A    raise Exception('We cannot enqueue because settings.USING_RABBITMQ is False.')%0A%0Aclass Command(BaseCommand):%0A    help = %22%22%22Read JSON lines from a file and enqueue them to a worker queue.%0A%0AEach line in the file should either be a JSON payload or two tab-separated%0Afields, the second of which is a JSON payload.  (The latter is to accomodate%0Athe format of error files written by queue workers that catch exceptions--their%0Afirst field is a timestamp that we ignore.)%0A%0AUsage: python manage.py enqueue_file %3Cqueue_name%3E %3Cfile_name%3E%0A%0AYou can use %22-%22 to represent stdin.%0A%22%22%22%0A%0A    def handle(self, *args, **options):%0A        if len(args) != 2:%0A            print %22Please provide a queue and file name.%22%0A            exit(1)%0A%0A        queue_name, file_name = args%0A%0A        if file_name == '-':%0A            f = sys.stdin%0A        else:%0A            f = open(file_name)%0A%0A        while True:%0A            line = f.readline()%0A            if not line:%0A                break%0A%0A            line = line.strip()%0A            try:%0A                payload = line.split('%5Ct')%5B1%5D%0A            except IndexError:%0A                payload = line%0A%0A            print 'Queueing to queue %25s: %25s' %25 (queue_name, payload)%0A%0A            # Verify that payload is valid json.%0A            data = ujson.loads(payload)%0A%0A            queue_json_publish(queue_name, data, error)%0A

Add enqueue_file management command.