Exemple #1
0
    def test_load_handlers_duplicate(self):

        with self.assertRaises(HandlerConfigError):
            load_handlers({
                'rfxcom.protocol.Status': 'home.collect.logging_handler',
                Status: 'home.collect.logging_handler',
            })
Exemple #2
0
    def test_load_handlers_wildcard(self):

        result = load_handlers({
            '*': 'home.collect.logging_handler',
        })

        self.assertEqual(result, {
            '*': logging_handler
        })
Exemple #3
0
    def test_load_handlers_all_objects(self):

        h = lambda x: x

        result = load_handlers({
            Status: h,
        })

        self.assertEqual(result, {
            Status: h
        })
Exemple #4
0
def collect(dev_name=None, callbacks=None):

    if callbacks is None:
        callbacks = dict(load_handlers(config.PACKET_HANDLERS))

    loop = get_event_loop()

    try:
        logger.info("Starting collection from:", dev_name)
        AsyncioTransport(dev_name, loop, callbacks=callbacks)
        loop.run_forever()
    finally:
        loop.close()
Exemple #5
0
def collect(dev_name=None, callbacks=None):

    if callbacks is None:
        callbacks = dict(load_handlers(config.PACKET_HANDLERS))

    loop = get_event_loop()

    try:
        logger.info("Starting collection from:", dev_name)
        AsyncioTransport(dev_name, loop, callbacks=callbacks)
        loop.run_forever()
    finally:
        loop.close()
Exemple #6
0
    def test_load_handlers_bad_path(self):

        with self.assertRaises(ImportError):
            load_handlers({
                'rfxcom.protocol..Status': 'home.collect.logging_handler'
            })
Exemple #7
0
    def test_load_handlers_empty(self):

        result = load_handlers({})

        self.assertEqual(result, {})