示例#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)
        ])
示例#2
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.using(config_values.functional).add_overrides(
        {'single_light_discover': True})
    settings_init.apply_env()

    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))
示例#3
0
    def setUp(self):
        injection.configure()
        settings.using({
            'log_to_console': True,
            'single_light_discover': True,
            'use_fakes': True
        }).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]
        fake_lifx.using([
            (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)
        ]).configure()
        light_set.configure()
示例#4
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.using(config_values.functional)
    settings_init.add_overrides(overrides).configure()
    light_module.configure()
    machine.Machine().run(build_instructions())
示例#5
0
    def test_simple(self):
        injection.configure()
        injection.bind(Impl1).to(Interface)
        self.assertEqual(1, call_impl())

        injection.configure()
        injection.bind(Impl2).to(Interface)
        self.assertEqual(2, call_impl())
示例#6
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()
示例#7
0
def configure():
    injection.configure()

    settings_init = settings.using(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)
示例#8
0
 def setUp(self):
     injection.configure()
     settings.use_base({'manifest_name': None}).configure()
示例#9
0
def configure():
    injection.configure()
    settings.using(config_values.functional).apply_env().configure()
    light_module.configure()
示例#10
0
 def configure(cls):
     injection.configure()
     settings.use_base(config_values.functional).configure()
     light_module.configure()
     LsModule._jobs = job_control.JobControl()
示例#11
0
 def test_provide(self):
     injection.configure()
     injection.bind(Impl1).to(Interface)
     self.assertEqual(1, call_impl_provided())
示例#12
0
 def test_object(self):
     injection.configure()
     injection.bind_instance(ImplN(5)).to(Interface)
     self.assertEqual(5, call_impl())
示例#13
0
 def setUp(self):
     injection.configure()
     settings.using(_log_settings).configure()
示例#14
0
 def setUp(self):
     injection.configure()
     self._precision = 0.1
     settings.use_base({'sleep_time': self._precision}).configure()