Esempio n. 1
0
    def test_hpfriends(self):
        """
        Objective: Test if data can be published to hpfriends without errors.
        """

        host = 'hpfriends.honeycloud.net'
        port = 20000
        ident = 'HBmU08rR'
        secret = 'XDNNuMGYUuWFaWyi'
        channels = ["test.test", ]
        hpf = HPFriendsLogger(host, port, ident, secret, channels)

        error_message = hpf.log('some some test data')
        self.assertIsNone(error_message, 'Unexpected error message: {0}'.format(error_message))
Esempio n. 2
0
class LogWorker(object):
    def __init__(self, config, log_queue):
        self.log_queue = log_queue
        self.sqlite_logger = None
        self.friends_feeder = None

        if config.getboolean('sqlite', 'enabled'):
            self.sqlite_logger = SQLiteLogger()
        if config.getboolean('hpfriends', 'enabled'):
            host = config.get('hpfriends', 'host')
            port = config.getint('hpfriends', 'port')
            ident = config.get('hpfriends', 'ident')
            secret = config.get('hpfriends', 'secret')
            channels = eval(config.get('hpfriends', 'channels'))
            try:
                self.friends_feeder = HPFriendsLogger(host, port, ident,
                                                      secret, channels)
            except Exception as e:
                logger.exception(e.message)
                self.friends_feeder = None
        self.enabled = True

    def start(self):
        self.enabled = True
        while self.enabled:
            event = self.log_queue.get()
            assert 'data_type' in event
            assert 'timestamp' in event

            if self.friends_feeder:
                self.friends_feeder.log(json.dumps(event))

            if self.sqlite_logger:
                self.sqlite_logger.log(event)

    def stop(self):
        self.enabled = False
Esempio n. 3
0
class LogWorker(object):
    def __init__(self, config, log_queue):
        self.log_queue = log_queue
        self.sqlite_logger = None
        self.friends_feeder = None

        if config.getboolean('sqlite', 'enabled'):
            self.sqlite_logger = SQLiteLogger()
        if config.getboolean('hpfriends', 'enabled'):
            host = config.get('hpfriends', 'host')
            port = config.getint('hpfriends', 'port')
            ident = config.get('hpfriends', 'ident')
            secret = config.get('hpfriends', 'secret')
            channels = eval(config.get('hpfriends', 'channels'))
            try:
                self.friends_feeder = HPFriendsLogger(host, port, ident, secret, channels)
            except Exception as e:
                logger.exception(e.message)
                self.friends_feeder = None
        self.enabled = True

    def start(self):
        self.enabled = True
        while self.enabled:
            event = self.log_queue.get()
            assert 'data_type' in event
            assert 'timestamp' in event

            if self.friends_feeder:
                self.friends_feeder.log(json.dumps(event))

            if self.sqlite_logger:
                self.sqlite_logger.log(event)

    def stop(self):
        self.enabled = False
Esempio n. 4
0
    def test_hpfriends(self):
        """
        Objective: Test if data can be published to hpfriends without errors.
        """

        host = 'hpfriends.honeycloud.net'
        port = 20000
        ident = 'HBmU08rR'
        secret = 'XDNNuMGYUuWFaWyi'
        channels = [
            "test.test",
        ]
        hpf = HPFriendsLogger(host, port, ident, secret, channels)

        error_message = hpf.log('some some test data')
        self.assertIsNone(
            error_message,
            'Unexpected error message: {0}'.format(error_message))