2013-01-11 21:16:42 +01:00
|
|
|
from optparse import make_option
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
import simplejson
|
|
|
|
import pika
|
|
|
|
from zephyr.lib.actions import process_user_activity_event
|
2013-01-18 19:01:20 +01:00
|
|
|
from zephyr.lib.queue import SimpleQueueClient
|
2013-01-11 21:16:42 +01:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
option_list = BaseCommand.option_list
|
|
|
|
help = "Process UserActivity log messages."
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2013-01-17 23:15:40 +01:00
|
|
|
activity_queue = SimpleQueueClient.get_instance()
|
2013-01-11 21:16:42 +01:00
|
|
|
|
|
|
|
def callback(ch, method, properties, event):
|
|
|
|
print " [x] Received %r" % (event,)
|
|
|
|
process_user_activity_event(event)
|
|
|
|
|
|
|
|
print ' [*] Waiting for messages. To exit press CTRL+C'
|
|
|
|
activity_queue.register_json_consumer('user_activity', callback)
|
|
|
|
activity_queue.start_consuming()
|
|
|
|
|