示例#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',
            })
示例#2
0
    def test_load_handlers_wildcard(self):

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

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

        h = lambda x: x

        result = load_handlers({
            Status: h,
        })

        self.assertEqual(result, {
            Status: h
        })
示例#4
0
文件: loop.py 项目: 24vishnu/Python
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()
示例#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()
示例#6
0
    def test_load_handlers_bad_path(self):

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

        result = load_handlers({})

        self.assertEqual(result, {})