<commit_before>#!/usr/bin/env python

import time
import sys
import logging
from socketIO_client import SocketIO

APPKEY = '5697113d4407a3cd028abead'
TOPIC = 'test'
ALIAS = 'test'

logger = logging.getLogger('messenger')

class Messenger:

    def __init__(self, appkey, alias, customid):
        self.__logger = logging.getLogger('messenger.Messenger')
        self.__logger.info('init')

        self.appkey = appkey
        self.customid = customid
        self.alias = alias

        self.socketIO = SocketIO('sock.yunba.io', 3000)
        self.socketIO.on('socketconnectack', self.on_socket_connect_ack)
        self.socketIO.on('connack', self.on_connack)
        self.socketIO.on('puback', self.on_puback)
        self.socketIO.on('suback', self.on_suback)
        self.socketIO.on('message', self.on_message)
        self.socketIO.on('set_alias_ack', self.on_set_alias)
        self.socketIO.on('get_topic_list_ack', self.on_get_topic_list_ack)
        self.socketIO.on('get_alias_list_ack', self.on_get_alias_list_ack)
#        self.socketIO.on('puback', self.on_publish2_ack)
        self.socketIO.on('recvack', self.on_publish2_recvack)
        self.socketIO.on('get_state_ack', self.on_get_state_ack)
        self.socketIO.on('alias', self.on_alias)

    def __del__(self):
        self.__logger.info('del')

    def loop(self):
        self.socketIO.wait(seconds=0.002)

    def on_socket_connect_ack(self, args):
        self.__logger.debug('on_socket_connect_ack: %s', args)
        self.socketIO.emit('connect', {'appkey': self.appkey, 'customid': self.customid})

    def on_connack(self, args):
        self.__logger.debug('on_connack: %s', args)

    def on_puback(self, args):
        self.__logger.debug('on_puback: %s', args)

    def on_suback(self, args):
        self.__logger.debug('on_suback: %s', args)
        self.socketIO.emit('set_alias', {'alias': self.alias})

    def on_message(self, args):
        self.__logger.debug('on_message: %s', args)

    def on_set_alias(self, args):
        self.__logger.debug('on_set_alias: %s', args)

    def on_get_alias(self, args):
        self.__logger.debug('on_get_alias: %s', args)

    def on_alias(self, args):
        self.__logger.debug('on_alias: %s', args)

    def on_get_topic_list_ack(self, args):
        self.__logger.debug('on_get_topic_list_ack: %s', args)

    def on_get_alias_list_ack(self, args):
        self.__logger.debug('on_get_alias_list_ack: %s', args)

    def on_publish2_ack(self, args):
        self.__logger.debug('on_publish2_ack: %s', args)

    def on_publish2_recvack(self, args):
        self.__logger.debug('on_publish2_recvack: %s', args)<commit_msg>Set messenger alias<commit_after>#!/usr/bin/env python

import time
import sys
import logging
from socketIO_client import SocketIO

APPKEY = '5697113d4407a3cd028abead'
TOPIC = 'test'
ALIAS = 'test'

logger = logging.getLogger('messenger')

class Messenger:

    def __init__(self, appkey, alias, customid):
        self.__logger = logging.getLogger('messenger.Messenger')
        self.__logger.info('init')

        self.appkey = appkey
        self.customid = customid
        self.alias = alias

        self.socketIO = SocketIO('sock.yunba.io', 3000)
        self.socketIO.on('socketconnectack', self.on_socket_connect_ack)
        self.socketIO.on('connack', self.on_connack)
        self.socketIO.on('puback', self.on_puback)
        self.socketIO.on('suback', self.on_suback)
        self.socketIO.on('message', self.on_message)
        self.socketIO.on('set_alias_ack', self.on_set_alias)
        self.socketIO.on('get_topic_list_ack', self.on_get_topic_list_ack)
        self.socketIO.on('get_alias_list_ack', self.on_get_alias_list_ack)
#        self.socketIO.on('puback', self.on_publish2_ack)
        self.socketIO.on('recvack', self.on_publish2_recvack)
        self.socketIO.on('get_state_ack', self.on_get_state_ack)
        self.socketIO.on('alias', self.on_alias)

    def __del__(self):
        self.__logger.info('del')

    def loop(self):
        self.socketIO.wait(seconds=0.002)

    def on_socket_connect_ack(self, args):
        self.__logger.debug('on_socket_connect_ack: %s', args)
        self.socketIO.emit('connect', {'appkey': self.appkey, 'customid': self.customid})

    def on_connack(self, args):
        self.__logger.debug('on_connack: %s', args)
        self.socketIO.emit('set_alias', {'alias': self.alias})

    def on_puback(self, args):
        self.__logger.debug('on_puback: %s', args)

    def on_suback(self, args):
        self.__logger.debug('on_suback: %s', args)

    def on_message(self, args):
        self.__logger.debug('on_message: %s', args)

    def on_set_alias(self, args):
        self.__logger.debug('on_set_alias: %s', args)

    def on_get_alias(self, args):
        self.__logger.debug('on_get_alias: %s', args)

    def on_alias(self, args):
        self.__logger.debug('on_alias: %s', args)

    def on_get_topic_list_ack(self, args):
        self.__logger.debug('on_get_topic_list_ack: %s', args)

    def on_get_alias_list_ack(self, args):
        self.__logger.debug('on_get_alias_list_ack: %s', args)

    def on_publish2_ack(self, args):
        self.__logger.debug('on_publish2_ack: %s', args)

    def on_publish2_recvack(self, args):
        self.__logger.debug('on_publish2_recvack: %s', args)
{'fraction_non_alphanumeric': 0.13551051051051052, 'fraction_numerical': 0.010885885885885885, 'mean_word_length': 3.4519632414369257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6570064', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1851, 'n_words': 299}