Ejemplo n.º 1
0
    def test_g3_config(self, init_dev):
        config = self.load_g3_config()
        self.assertEqual(len(config.controllers), 5, 'not all controllers recognized in config')
        for controller in config.controllers:
            self.assertEqual(controller.get('type'), 'g3')
            self.assertIn('unit', controller)

            ThermaltakeController.factory(controller.get('type'))
            self.assertTrue(init_dev.called)
Ejemplo n.º 2
0
    def __init__(self):
        LOGGER.info('initializing thermaltake rgb daemon')

        LOGGER.debug('loading config')
        self.config = Config()

        LOGGER.debug('creating fan manager')
        fan_model = FanModel.factory(self.config.fan_manager)
        self.fan_manager = FanManager(fan_model)

        LOGGER.debug('creating lighting manager')
        self.lighting_manager = LightingEffect.factory(
            self.config.lighting_manager)

        self.attached_devices = {}
        self.controllers = {}

        LOGGER.debug('configuring controllers')
        for controller in self.config.controllers:
            self.controllers[
                controller['unit']] = ThermaltakeController.factory(
                    controller['type'], controller.get('unit'))
            for id, model in controller['devices'].items():
                LOGGER.debug(' configuring devices for controller %s: %s',
                             controller['type'], controller.get('unit'))
                dev = ThermaltakeDevice.factory(
                    model, self.controllers[controller['unit']], id)
                self.controllers[controller['unit']].attach_device(id, dev)
                self.register_attached_device(controller['unit'], id, dev)

        self._continue = False
 def test_controller_factory(self, init_dev):
     for type_ in ('g3', ):
         for case_variant in (str.lower, str.upper, str):
             self.assertIsInstance(
                 ThermaltakeController.factory(case_variant(type_)),
                 ThermaltakeController, '{} not recognized'.format(type_))
             self.assertTrue(
                 init_dev.called,
                 '{} did not initialize the driver'.format(type_))
Ejemplo n.º 4
0
    def test_device_factory(self, init_dev):
        controller = ThermaltakeController.factory('g3')
        for i, clazz in enumerate(ThermaltakeDevice.inheritors()):
            if clazz.model is None:
                continue

            dev = ThermaltakeDevice.factory(clazz.model, controller, 1)
            controller.attach_device(i, dev)
            self.assertIsInstance(ThermaltakeDevice.factory(clazz.model, controller, 1), clazz)
            self.assertTrue(init_dev.called)
Ejemplo n.º 5
0
logging.basicConfig(stream=sys.stdout,
                    level=logging.DEBUG,
                    format='%(message)s')

self_config = Config()
self_lighting_manager = LightingEffect.factory(self_config.lighting_manager)
self_fan_manager = None

self_attached_devices = {}
self_controllers = {}

self_attached_devices = {}
LOGGER.debug('configuring controllers')
for controller in self_config.controllers:
    self_controllers[controller['unit']] = ThermaltakeController.factory(
        controller['type'], controller.get('unit'))
    for id, model in controller['devices'].items():
        dev = ThermaltakeDevice.factory(model,
                                        self_controllers[controller['unit']],
                                        id)
        self_controllers[controller['unit']].attach_device(id, dev)

        if isinstance(dev, devices.ThermaltakeFanDevice) and self_fan_manager:
            LOGGER.debug('  registering %s with fan manager', dev.model)
            self_fan_manager.attach_device(dev)
        if isinstance(dev,
                      devices.ThermaltakeRGBDevice) and self_lighting_manager:
            LOGGER.debug('  registering %s with lighting manager', dev.model)
            self_lighting_manager.attach_device(dev)

        self_attached_devices[f'{model}:{id}'] = dev