示例#1
0
    def __init__(self):
        proctitle('bot')
        log.info('bot started with PID=%d' % os.getpid())

        self._jid = "%s/%s" % (settings.xmpp_jid, settings.xmpp_resource)
        sleekxmpp.ClientXMPP.__init__(self, self._jid, settings.xmpp_password)

        self.register_plugin('xep_0184')
        self.register_plugin('xep_0163')
        self.plugin['xep_0163'].add_interest('http://jabber.org/protocol/tune')
        self.plugin['xep_0060'].map_node_event('http://jabber.org/protocol/tune', 'user_tune')

        self.add_event_handler("session_start", self.session_start)
        self.add_event_handler("message", self.handle_message)
        self.add_event_handler("presence_subscribed", self.handle_subscription)
        self.add_event_handler("user_tune_publish", self.handle_tune)
        self.add_event_handler("got_offline", self.handle_disconnection)

        self.add_event_handler("receipt_received", self.handle_receipt)

        self.xin = Queue('xin', addr=settings.queue_socket)
        self.xout = Queue('xout', addr=settings.queue_socket)

        self.auto_authorize = True
        self.auto_subscribe = True

        spawn(self.listen_queue)
示例#2
0
    def __init__(self):
        proctitle('bot')
        log.info('bot started with PID=%d' % os.getpid())

        self._jid = "%s/%s" % (settings.xmpp_jid, settings.xmpp_resource)
        sleekxmpp.ClientXMPP.__init__(self, self._jid, settings.xmpp_password)

        self.register_plugin('xep_0184')
        self.register_plugin('xep_0163')
        self.plugin['xep_0163'].add_interest('http://jabber.org/protocol/tune')
        self.plugin['xep_0060'].map_node_event(
            'http://jabber.org/protocol/tune', 'user_tune')

        self.add_event_handler("session_start", self.session_start)
        self.add_event_handler("message", self.handle_message)
        self.add_event_handler("presence_subscribed", self.handle_subscription)
        self.add_event_handler("user_tune_publish", self.handle_tune)
        self.add_event_handler("got_offline", self.handle_disconnection)

        self.add_event_handler("receipt_received", self.handle_receipt)

        self.xin = Queue('xin', addr=settings.queue_socket)
        self.xout = Queue('xout', addr=settings.queue_socket)

        self.auto_authorize = True
        self.auto_subscribe = True

        spawn(self.listen_queue)
示例#3
0
    def __init__(self):
        proctitle('feed-manager')
        log.info('FeedManager started with PID=%d' % os.getpid())

        self.fqueue = Queue('fqueue', settings.feed_queue_socket,
                            channels=False)

        #gevent.spawn(self.put_tasks)
        gevent.joinall([gevent.spawn(self.run)])
示例#4
0
    def __init__(self):
        proctitle('feed-manager')
        log.info('FeedManager started with PID=%d' % os.getpid())

        self.fqueue = Queue('fqueue',
                            settings.feed_queue_socket,
                            channels=False)

        #gevent.spawn(self.put_tasks)
        gevent.joinall([gevent.spawn(self.run)])
示例#5
0
    def __init__(self):
        proctitle('sender-queue')
        log.info('sender queue started with PID=%s' % os.getpid())

        self.xsq = Queue('xsq', settings.queue_socket)

        pool = RedisPool(settings.pubsub_socket)
        pubsub = pool.pubsub()
        pubsub.subscribe(['msg', 'sub', 'rec', 'confirm', 'remember'])

        for msg in pubsub.listen():
            self.xsq.push("%s %s" % (msg['channel'], msg['data']))
示例#6
0
    def __init__(self):
        proctitle('sender-queue')
        log.info('sender queue started with PID=%s' % os.getpid())

        self.xsq = Queue('xsq', settings.queue_socket)

        pool = RedisPool(settings.pubsub_socket)
        pubsub = pool.pubsub()
        pubsub.subscribe(['msg', 'sub', 'rec', 'confirm', 'remember'])

        for msg in pubsub.listen():
            self.xsq.push("%s %s" % (msg['channel'], msg['data']))
示例#7
0
    def __init__(self):
        proctitle('feed-worker')
        log.info('FeedWorker started with PID=%d' % os.getpid())

        self.fqueue = Queue('fqueue', settings.feed_queue_socket)

        while True:
            data = self.fqueue.pop()
            if not data or 'id' not in data or not data['id']:
                continue

            try:
                gevent.spawn(self.update_feed, int(data['id']))
            except ValueError:
                continue
示例#8
0
    def __init__(self):
        proctitle('support-worker')
        log.info('support worker started with PID=%s' % os.getpid())

        pool = RedisPool(settings.pubsub_socket)
        pubsub = pool.pubsub()
        pubsub.subscribe(['msg'])

        for msg in pubsub.listen():
            try:
                data = json.loads(msg['data'])
            except TypeError:
                continue
            if data['a'] in ('post', 'post_edited'):
                gevent.spawn(self.handle_post, data)
示例#9
0
    def __init__(self):
        proctitle('sender')
        log.info('sender started with PID=%s' % os.getpid())

        self.xsq = Queue('xsq', settings.queue_socket)
        self.xout = Queue('xout', settings.queue_socket)

        while True:
            msg = self.xsq.pop()
            if msg:
                channel, msg = msg.split(' ', 1)
                data = json.loads(msg)
                if isinstance(data, int):
                    continue
                gevent.spawn(self.handle_message, channel, data)
示例#10
0
    def __init__(self):
        proctitle('sender')
        log.info('sender started with PID=%s' % os.getpid())

        self.xsq = Queue('xsq', settings.queue_socket)
        self.xout = Queue('xout', settings.queue_socket)

        while True:
            msg = self.xsq.pop()
            if msg:
                channel, msg = msg.split(' ', 1)
                data = json.loads(msg)
                if isinstance(data, int):
                    continue
                gevent.spawn(self.handle_message, channel, data)
示例#11
0
    def __init__(self):
        proctitle('worker')
        log.info('worker started with PID=%s' % os.getpid())

        self.route = prepare_route(route)

        self.qin = Queue('xin', settings.queue_socket)
        self.qout = Queue('xout', settings.queue_socket)

        while True:
            data = self.qin.pop()
            if data:
                try:
                    data = json.loads(data)
                    gevent.spawn(self.handle_message, data)
                except ValueError, err:
                    log.error("%s: %s" % (err.__class__.__name__, err.message))
示例#12
0
    def __init__(self):
        proctitle("worker")
        log.info("worker started with PID=%s" % os.getpid())

        self.route = prepare_route(route)

        self.qin = Queue("xin", settings.queue_socket)
        self.qout = Queue("xout", settings.queue_socket)

        while True:
            data = self.qin.pop()
            if data:
                try:
                    data = json.loads(data)
                    data_type = data.get("type", "msg")
                    if data_type == "msg":
                        method = self.handle_message
                    elif data_type == "tune":
                        method = self.handle_tune
                    gevent.spawn(method, data)
                except ValueError, err:
                    log.error("%s: %s" % (err.__class__.__name__, err.message))
示例#13
0
    def __init__(self):
        proctitle('bot')
        log.info('bot started with PID=%d' % os.getpid())

        self._jid = "%s/%s" % (settings.xmpp_jid, settings.xmpp_resource)
        sleekxmpp.ClientXMPP.__init__(self, self._jid, settings.xmpp_password)

        self.register_plugin('xep_0184')

        self.add_event_handler("session_start", self.session_start)
        self.add_event_handler("message", self.handle_message)
        self.add_event_handler("presence_subscribed", self.handle_subscription)

        self.add_event_handler("receipt_received", self.handle_receipt)

        self.xin = Queue('xin', addr=settings.queue_socket)
        self.xout = Queue('xout', addr=settings.queue_socket)

        self.auto_authorize = True
        self.auto_subscribe = True

        spawn(self.listen_queue)
示例#14
0
class ImgprocWorker(object):
    proctitle('imgproc-worker')
    def __init__(self):
        self.queue = Queue('imgq', settings.imgproc_socket)

        log.info('imgproc worker started')

        while True:
            data = self.queue.pop()
            if data and isinstance(data, dict):
                fn = data['fn']
                del data['fn']
                try:
                    handlers[fn](**data)
                except Exception, e:
                    log.error(traceback.format_exc())