def _enable_all_plugins(self, include_admin=False, write_to_disk=False): plugins = get_plugins_with_dtmf_sequence(include_admin=include_admin) for plugin_instance in plugins.values(): set_plugin_config_option(plugin_instance.ID, "enable", "True", write_to_disk=write_to_disk)
def assertAllPluginsAreDisabled(self, include_admin=False): plugins = get_plugins_with_dtmf_sequence(include_admin=include_admin) for plugin_instance in plugins.values(): value = get_plugin_config_option(plugin_instance.ID, "enable", "bool") self.assertFalse( value, "Plugin %s is enabled, but it should be disabled" % (plugin_instance.ID))
def run(self): plugins = get_plugins_with_dtmf_sequence(include_admin=False) for dtmf_sequence, plugin_instance in plugins.items(): set_plugin_config_option(plugin_instance.ID, "enable", "False", write_to_disk=True) self.say("All non-admin DTMF plugins disabled.")
def run(self): plugins = get_plugins_with_dtmf_sequence(include_admin=False) text_to_say = "Available commands:" for index, plugin_class in enumerate(plugins.values()): sequence_text = "" for char in plugin_class.DTMF_SEQUENCE: sequence_text += char + " " text_to_say += "\n%s. Sequence %s. %s" % ( index + 1, sequence_text, plugin_class.DESCRIPTION, ) self.say(text_to_say)
def initialize( self, dev_mode: bool = False, emulator_mode: bool = False, offline_mode: bool = False, debug: bool = False, ): # 1. Configure logging configure_logging(get_config_option("main", "logging_config"), debug=debug) wx_server_load_and_parse_config(WX_SERVER_CONFIG_PATH) if dev_mode: LOG.info("Development mode is active") set_config_option("main", "dev_mode", "True") if emulator_mode: LOG.info("Running in emulator mode") set_config_option("main", "emulator_mode", "True") if offline_mode: LOG.info( "Running in offline mode. Only plugins which don't require internet " 'connection will be available and using "espeak" TTS engine.') set_config_option("main", "offline_mode", "True") set_config_option("tts", "implementation", "espeak") self._emulator_mode = get_config_option("main", "emulator_mode", "bool", fallback=False) self._dev_mode = get_config_option("main", "dev_mode", "bool", fallback=False) self._offline_mode = get_config_option("main", "offline_mode", "bool", fallback=False) # 2. Load and register plugins self._all_plugins = get_available_plugins() self._dtmf_plugins = get_plugins_with_dtmf_sequence() self._sequence_to_plugin_map = self._dtmf_plugins # Filter out plugins in offline mode # TODO: Move that functionality to get_ methods if self._offline_mode: self._all_plugins = { name: instance for (name, instance) in self._all_plugins.items() if instance.REQUIRES_INTERNET_CONNECTION is False } self._dtmf_plugins = { name: instance for (name, instance) in self._dtmf_plugins.items() if instance.REQUIRES_INTERNET_CONNECTION is False } # 3. Generate OTPs all_otps, _ = generate_and_write_otps() LOG.info("Generated and unused OTPs for admin commands", otps=all_otps)