Exemplo n.º 1
0
    def setUp(self):
        injection.configure()
        settings.use_base({
            'log_to_console': True,
            'single_light_discover': True,
            'use_fakes': True
        }).configure()
        fake_lifx.configure()
        light_set.configure()

        self._group0 = 'Group 0'
        self._group1 = 'Group 1'
        self._group2 = 'Group 2'

        self._location0 = 'Location 0'
        self._location1 = 'Location 1'
        self._location2 = 'Location 2'

        self._light0 = 'Light 0'
        self._light1 = 'Light 1'
        self._light2 = 'Light 2'
        self._light3 = 'Light 3'

        self._color = [1, 2, 3, 4]
        lifx = injection.provide(i_controller.Lifx)
        lifx.init_from([
            (self._light0, self._group0, self._location0, self._color, False),
            (self._light1, self._group0, self._location1, self._color, False),
            (self._light2, self._group1, self._location0, self._color, False),
            (self._light3, self._group1, self._location1, self._color, False)
        ])
Exemplo n.º 2
0
def configure():
    injection.configure()
    settings.use_base({
        'log_level': logging.ERROR,
        'log_to_console': True,
        'single_light_discover': True,
        'use_fakes': True
    }).configure()
    log_config.configure()
    fake_clock.configure()
    fake_lifx.configure()
    light_set.configure()
Exemplo n.º 3
0
def main():
    injection.configure()

    ap = argparse.ArgumentParser()
    ap.add_argument(
        '-v', '--verbose', help='do debug-level logging', action='store_true')
    ap.add_argument(
        '-f', '--fakes', help='use fake lights', action='store_true')
    arg_helper.add_n_argument(ap)
    args = ap.parse_args()

    overrides = {
        'sleep_time': 0.1
    }
    if args.verbose:
        overrides['log_level'] = logging.DEBUG
        overrides['log_to_console'] = True
    if args.fakes:
        overrides['use_fakes'] = True
    n_arg = arg_helper.get_overrides(args)
    if n_arg is not None and not args.fakes:
        overrides.update(n_arg)

    settings_init = settings.use_base(config_values.functional)
    settings_init.add_overrides(overrides).configure()
    light_module.configure()
    machine.Machine().run(build_instructions())
Exemplo n.º 4
0
def configure():
    injection.configure()

    settings_init = settings.use_base(config_values.functional)
    settings_init.add_overrides({
        'log_to_console': False
    })
    ini = os.getenv('BARDOLPH_INI')
    if ini:
        settings_init.apply_file(ini)
    settings_init.configure()

    light_module.configure()
    injection.bind_instance(web_app.WebApp()).to(i_web.WebApp)
Exemplo n.º 5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-l', '--list', help='output instruction list', action='store_true')
    parser.add_argument(
        '-d', '--dict', help='output dictionary format', action='store_true')
    parser.add_argument(
        '-f', '--use-fakes', help='use fake lights', action='store_true')
    arg_helper.add_n_argument(parser)
    parser.add_argument(
        '-p', '--py', help='output Python code', action='store_true')
    parser.add_argument(
        '-s', '--script', help='output script format', action='store_true')
    parser.add_argument(
        '-t', '--text', help='output text format', action='store_true')
    args = parser.parse_args()
    do_script = args.script
    do_dict = args.dict
    do_list = args.list
    do_py = args.py
    do_text = args.text or (not (do_py or do_script or do_dict or do_list))

    injection.configure()
    settings_init = settings.use_base(
        config_values.functional).add_overrides({'single_light_discover': True})
    if args.use_fakes:
        settings_init.add_overrides({'use_fakes': True})
    n_arg = arg_helper.get_overrides(args)
    if n_arg is not None:
        settings_init.add_overrides(n_arg)
    settings_init.configure()
    light_module.configure()

    if do_dict:
        _do_gen(DictSnapshot)
    if do_list:
        _do_gen(InstructionSnapshot)
    if do_script:
        _do_gen(ScriptSnapshot)
    if do_text:
        _do_gen(TextSnapshot)
    if do_py:
        snap = InstructionSnapshot()
        text = '    OpCode.MOVEQ, UnitMode.RAW, Register.UNIT_MODE,\n'
        text += snap.generate().text
        lsc.output_python(lsc.program_code(text))
Exemplo n.º 6
0
 def setUp(self):
     injection.configure()
     settings.use_base({'manifest_name': None}).configure()
Exemplo n.º 7
0
 def test_apply_file(self):
     settings.use_base(base).apply_file(
         'tests/test_apply_file.ini').configure()
     s = settings.Settings()
     self.assertEqual('11', s.get_value('one'))
     self.assertEqual('22', s.get_value('two'))
Exemplo n.º 8
0
 def test_override(self):
     settings.use_base(base).add_overrides(override).configure()
     s = settings.Settings()
     self.assertEqual(1, s.get_value('one'))
     self.assertEqual(22, s.get_value('two'))
     self.assertEqual(4, s.get_value('four'))
Exemplo n.º 9
0
 def test_base(self):
     settings.use_base(base).configure()
     s = settings.Settings()
     self.assertEqual(1, s.get_value('one'))
     self.assertEqual(2, s.get_value('two'))
Exemplo n.º 10
0
 def configure(cls):
     injection.configure()
     settings.use_base(config_values.functional).configure()
     light_module.configure()
     LsModule._jobs = job_control.JobControl()
Exemplo n.º 11
0
 def setUp(self):
     injection.configure()
     settings.use_base(_log_settings).configure()
Exemplo n.º 12
0
 def setUp(self):
     injection.configure()
     self._precision = 0.1
     settings.use_base({'sleep_time': self._precision}).configure()