Ejemplo n.º 1
0
    def test_pass_lang_code_positionally(self):
        lingua_franca.load_languages(['en', 'es'])

        self.assertEqual(
            lingua_franca.parse.extract_number("dos", True, False, 'es'),
            2)
        unload_all_languages()
Ejemplo n.º 2
0
    def test_set_default_language(self):
        lingua_franca.load_languages(['es', 'en'])
        lingua_franca.set_default_lang('en')
        self.assertEqual(lingua_franca.get_default_lang(), 'en')
        unload_all_languages()

        with self.assertRaises(ValueError):
            lingua_franca.set_default_lang('foobar')
Ejemplo n.º 3
0
    def test_auto_default_language(self):
        lingua_franca.load_language('en')

        # Load two languages, ensure first is default
        lingua_franca.load_languages(['en', 'es'])
        self.assertEqual(lingua_franca.get_default_lang(), 'en')
        self.assertEqual(lingua_franca.parse.extract_number('one'), 1)
        unload_all_languages()
Ejemplo n.º 4
0
 def test_set_active_langs(self):
     unload_all_languages()
     lingua_franca.load_languages(['en', 'es'])
     self.assertEqual(lingua_franca.get_active_langs(), ['en', 'es'])
     lingua_franca._set_active_langs('es')
     self.assertEqual(lingua_franca.get_default_lang(), 'es')
     self.assertFalse('en' in lingua_franca.get_active_langs())
     unload_all_languages()
     with self.assertRaises(TypeError):
         lingua_franca._set_active_langs(157.75)
Ejemplo n.º 5
0
def main(alive_hook=on_alive,
         started_hook=on_started,
         ready_hook=on_ready,
         error_hook=on_error,
         stopping_hook=on_stopping,
         watchdog=None):
    reset_sigint_handler()
    # Create PID file, prevent multiple instances of this service
    mycroft.lock.Lock('skills')
    config = Configuration.get()
    lang_code = config.get("lang", "en-us")
    load_languages([lang_code, "en-us"])

    # Connect this process to the Mycroft message bus
    bus = start_message_bus_client("SKILLS")
    _register_intent_services(bus)
    event_scheduler = EventScheduler(bus)
    callbacks = StatusCallbackMap(on_started=started_hook,
                                  on_alive=alive_hook,
                                  on_ready=ready_hook,
                                  on_error=error_hook,
                                  on_stopping=stopping_hook)
    status = ProcessStatus('skills', bus, callbacks)

    SkillApi.connect_bus(bus)
    skill_manager = _initialize_skill_manager(bus, watchdog)

    status.set_started()
    _wait_for_internet_connection()

    if skill_manager is None:
        skill_manager = _initialize_skill_manager(bus, watchdog)

    device_primer = DevicePrimer(bus, config)
    device_primer.prepare_device()
    skill_manager.start()
    while not skill_manager.is_alive():
        time.sleep(0.1)
    status.set_alive()

    while not skill_manager.is_all_loaded():
        time.sleep(0.1)
    status.set_ready()

    wait_for_exit_signal()
    status.set_stopping()
    shutdown(skill_manager, event_scheduler)
Ejemplo n.º 6
0
def setUpModule():
    load_languages(get_supported_langs())
    # TODO spin English tests off into another file, like other languages, so we
    # don't have to do this confusing thing in the "master" test_format.py
    set_default_lang('en-us')