• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python configuration.ConfigurationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mycroft.configuration.ConfigurationManager的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager类的具体用法?Python ConfigurationManager怎么用?Python ConfigurationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ConfigurationManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    global ws
    global loop
    global config
    lock = PIDLock("voice")
    ws = WebsocketClient()
    config = ConfigurationManager.get()
    ConfigurationManager.init(ws)
    loop = RecognizerLoop()
    loop.on('recognizer_loop:utterance', handle_utterance)
    loop.on('speak', handle_speak)
    loop.on('recognizer_loop:record_begin', handle_record_begin)
    loop.on('recognizer_loop:wakeword', handle_wakeword)
    loop.on('recognizer_loop:record_end', handle_record_end)
    loop.on('recognizer_loop:no_internet', handle_no_internet)
    ws.on('open', handle_open)
    ws.on('complete_intent_failure', handle_complete_intent_failure)
    ws.on('recognizer_loop:sleep', handle_sleep)
    ws.on('recognizer_loop:wake_up', handle_wake_up)
    ws.on('mycroft.mic.mute', handle_mic_mute)
    ws.on('mycroft.mic.unmute', handle_mic_unmute)
    ws.on("mycroft.paired", handle_paired)
    ws.on('recognizer_loop:audio_output_start', handle_audio_start)
    ws.on('recognizer_loop:audio_output_end', handle_audio_end)
    ws.on('mycroft.stop', handle_stop)
    event_thread = Thread(target=connect)
    event_thread.setDaemon(True)
    event_thread.start()

    try:
        loop.run()
    except KeyboardInterrupt, e:
        LOG.exception(e)
        sys.exit()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:34,代码来源:main.py


示例2: main

def main():
    global ws
    global config
    ws = WebsocketClient()
    ConfigurationManager.init(ws)
    config = ConfigurationManager.get()
    speech.init(ws)

    # Setup control of pulse audio
    setup_pulseaudio_handlers(config.get('Audio').get('pulseaudio'))

    def echo(message):
        try:
            _message = json.loads(message)
            if 'mycroft.audio.service' not in _message.get('type'):
                return
            message = json.dumps(_message)
        except:
            pass
        LOG.debug(message)

    LOG.info("Staring Audio Services")
    ws.on('message', echo)
    ws.once('open', load_services_callback)
    try:
        ws.run_forever()
    except KeyboardInterrupt, e:
        LOG.exception(e)
        speech.shutdown()
        sys.exit()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:30,代码来源:main.py


示例3: main

def main():
    global ws
    lock = Lock('skills')  # prevent multiple instances of this service

    # Connect this Skill management process to the websocket
    ws = WebsocketClient()
    ConfigurationManager.init(ws)

    ignore_logs = ConfigurationManager.instance().get("ignore_logs")

    # Listen for messages and echo them for logging
    def _echo(message):
        try:
            _message = json.loads(message)

            if _message.get("type") in ignore_logs:
                return

            if _message.get("type") == "registration":
                # do not log tokens from registration messages
                _message["data"]["token"] = None
            message = json.dumps(_message)
        except:
            pass
        logger.debug(message)

    ws.on('message', _echo)

    # Startup will be called after websocket is full live
    ws.once('open', _starting_up)
    ws.run_forever()
开发者ID:Wolfgange3311999,项目名称:mycroft-core,代码行数:31,代码来源:main.py


示例4: handle_update_intent

 def handle_update_intent(self, message):
     identity = IdentityManager().get()
     if not identity.owner:
         self.speak_dialog("not.paired")
     else:
         ConfigurationManager.load_remote()
         self.speak_dialog("config.updated")
开发者ID:Acidburn0zzz,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py


示例5: main

def main():
    global ws
    global loop
    ws = WebsocketClient()
    tts.init(ws)
    ConfigurationManager.init(ws)
    loop = RecognizerLoop()
    loop.on('recognizer_loop:utterance', handle_utterance)
    loop.on('recognizer_loop:record_begin', handle_record_begin)
    loop.on('recognizer_loop:wakeword', handle_wakeword)
    loop.on('recognizer_loop:record_end', handle_record_end)
    loop.on('speak', handle_speak)
    ws.on('open', handle_open)
    ws.on('speak', handle_speak)
    ws.on(
        'multi_utterance_intent_failure',
        handle_multi_utterance_intent_failure)
    ws.on('recognizer_loop:sleep', handle_sleep)
    ws.on('recognizer_loop:wake_up', handle_wake_up)
    ws.on('mycroft.stop', handle_stop)
    ws.on("mycroft.paired", handle_paired)
    event_thread = Thread(target=connect)
    event_thread.setDaemon(True)
    event_thread.start()

    try:
        loop.run()
    except KeyboardInterrupt, e:
        logger.exception(e)
        event_thread.exit()
        sys.exit()
开发者ID:forslund,项目名称:mycroft-core,代码行数:31,代码来源:main.py


示例6: __init__

 def __init__(self, path):
     self.path = path
     config = ConfigurationManager().get()
     config_server = config.get("server")
     self.url = config_server.get("url")
     self.version = config_server.get("version")
     self.identity = IdentityManager.get()
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py


示例7: __init__

 def __init__(self):
     self.iface = pyw.winterfaces()[0]
     self.ap = AccessPoint(self.iface)
     self.server = None
     self.ws = WebsocketClient()
     ConfigurationManager.init(self.ws)
     self.enclosure = EnclosureAPI(self.ws)
     self.init_events()
     self.conn_monitor = None
     self.conn_monitor_stop = threading.Event()
开发者ID:forslund,项目名称:mycroft-core,代码行数:10,代码来源:main.py


示例8: __init__

 def __init__(self, key_phrase="hey mycroft", config=None, lang="en-us"):
     self.lang = str(lang).lower()
     self.key_phrase = str(key_phrase).lower()
     # rough estimate 1 phoneme per 2 chars
     self.num_phonemes = len(key_phrase) / 2 + 1
     if config is None:
         config = ConfigurationManager.get().get("hot_words", {})
         config = config.get(self.key_phrase, {})
     self.config = config
     self.listener_config = ConfigurationManager.get().get("listener", {})
开发者ID:aatchison,项目名称:mycroft-core,代码行数:10,代码来源:hotword_factory.py


示例9: __init__

 def __init__(self):
     self.ws = WebsocketClient()
     ConfigurationManager.init(self.ws)
     self.config = ConfigurationManager.get().get("enclosure")
     self.__init_serial()
     self.reader = EnclosureReader(self.serial, self.ws)
     self.writer = EnclosureWriter(self.serial, self.ws)
     self.writer.write("system.version")
     self.ws.on("enclosure.start", self.start)
     self.started = False
     Timer(5, self.stop).start()     # WHY? This at least needs an explaination, this is non-obvious behavior
开发者ID:forslund,项目名称:mycroft-core,代码行数:11,代码来源:__init__.py


示例10: setup

    def setup(self):
        must_upload = self.config.get('must_upload')
        if must_upload is not None and str2bool(must_upload):
            ConfigurationManager.set('enclosure', 'must_upload', False)
            self.upload_hex()

        must_start_test = self.config.get('must_start_test')
        if must_start_test is not None and str2bool(must_start_test):
            ConfigurationManager.set('enclosure', 'must_start_test', False)
            time.sleep(0.5)  # Ensure arduino has booted
            self.writer.write("test.begin")
开发者ID:kagesenshi,项目名称:mycroft-core,代码行数:11,代码来源:enclosure.py


示例11: __init__

    def __init__(self):
        self.ws = WebsocketClient()
        self.ws.on("open", self.on_ws_open)

        ConfigurationManager.init(self.ws)
        self.config = ConfigurationManager.instance().get("enclosure")
        self.__init_serial()
        self.reader = EnclosureReader(self.serial, self.ws)
        self.writer = EnclosureWriter(self.serial, self.ws)

        # initiates the web sockets on display manager
        # NOTE: this is a temporary place to initiate display manager sockets
        initiate_display_manager_ws()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:13,代码来源:__init__.py


示例12: __init_client

    def __init_client(self, params):
        config = ConfigurationManager.get().get("websocket")

        if not params.host:
            params.host = config.get('host')
        if not params.port:
            params.port = config.get('port')

        self.ws = WebsocketClient(host=params.host,
                                  port=params.port,
                                  ssl=params.use_ssl)

        # Connect configuration manager to message bus to receive updates
        ConfigurationManager.init(self.ws)
开发者ID:aatchison,项目名称:mycroft-core,代码行数:14,代码来源:container.py


示例13: __init__

    def __init__(self, args):
        params = self.__build_params(args)

        if params.config:
            ConfigurationManager.load_local([params.config])

        if exists(params.lib) and isdir(params.lib):
            sys.path.append(params.lib)

        sys.path.append(params.dir)
        self.dir = params.dir

        self.enable_intent = params.enable_intent

        self.__init_client(params)
开发者ID:aatchison,项目名称:mycroft-core,代码行数:15,代码来源:container.py


示例14: main

def main():
    import tornado.options
    lock = Lock("service")
    tornado.options.parse_command_line()

    def reload_hook():
        """ Hook to release lock when autoreload is triggered. """
        lock.delete()

    autoreload.add_reload_hook(reload_hook)

    config = ConfigurationManager.get().get("websocket")

    host = config.get("host")
    port = config.get("port")
    route = config.get("route")
    validate_param(host, "websocket.host")
    validate_param(port, "websocket.port")
    validate_param(route, "websocket.route")

    routes = [
        (route, WebsocketEventHandler)
    ]
    application = web.Application(routes, **settings)
    application.listen(port, host)
    ioloop.IOLoop.instance().start()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:26,代码来源:main.py


示例15: __init__

    def __init__(self, directory, name):
        super(SkillSettings, self).__init__()
        # when skills try to instantiate settings
        # in __init__, it can erase the settings saved
        # on disk (settings.json). So this prevents that
        # This is set to true in core.py after skill init
        self.allow_overwrite = False

        self.api = DeviceApi()
        self.config = ConfigurationManager.get()
        self.name = name
        self.directory = directory
        # set file paths
        self._settings_path = join(directory, 'settings.json')
        self._meta_path = join(directory, 'settingsmeta.json')
        self.is_alive = True
        self.loaded_hash = hash(str(self))
        self._complete_intialization = False
        self._device_identity = None
        self._api_path = None
        self._user_identity = None
        self.changed_callback = None

        # if settingsmeta exist
        if isfile(self._meta_path):
            self._poll_skill_settings()
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:26,代码来源:settings.py


示例16: __init__

    def __init__(self, emitter):
        FallbackSkill.__init__(self)
        self.config = ConfigurationManager.get()['padatious']
        intent_cache = expanduser(self.config['intent_cache'])

        try:
            from padatious import IntentContainer
        except ImportError:
            LOG.error('Padatious not installed. Please re-run dev_setup.sh')
            try:
                call(['notify-send', 'Padatious not installed',
                      'Please run build_host_setup and dev_setup again'])
            except OSError:
                pass
            return
        ver = get_distribution('padatious').version
        if ver != PADATIOUS_VERSION:
            LOG.warning('Using Padatious v' + ver + '. Please re-run ' +
                        'dev_setup.sh to install ' + PADATIOUS_VERSION)

        self.container = IntentContainer(intent_cache)

        self.emitter = emitter
        self.emitter.on('padatious:register_intent', self.register_intent)
        self.emitter.on('padatious:register_entity', self.register_entity)
        self.register_fallback(self.handle_fallback, 5)
        self.finished_training_event = Event()

        self.train_delay = self.config['train_delay']
        self.train_time = get_time() + self.train_delay
        self.wait_and_train()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:31,代码来源:padatious_service.py


示例17: create

    def create():
        """
        Factory method to create a TTS engine based on configuration.

        The configuration file ``mycroft.conf`` contains a ``tts`` section with
        the name of a TTS module to be read by this method.

        "tts": {
            "module": <engine_name>
        }
        """

        from mycroft.tts.remote_tts import RemoteTTS
        config = ConfigurationManager.get().get('tts', {})
        module = config.get('module', 'mimic')
        lang = config.get(module).get('lang')
        voice = config.get(module).get('voice')
        clazz = TTSFactory.CLASSES.get(module)

        if issubclass(clazz, RemoteTTS):
            url = config.get(module).get('url')
            tts = clazz(lang, voice, url)
        else:
            tts = clazz(lang, voice)

        tts.validator.validate()
        return tts
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:27,代码来源:__init__.py


示例18: setup

    def setup(self):
        must_upload = self.config.get('must_upload')
        if must_upload is not None and str2bool(must_upload):
            ConfigurationManager.set('enclosure', 'must_upload', False)
            time.sleep(5)
            self.client.emit(Message("speak", metadata={
                'utterance': "I am currently uploading to the arduino."}))
            self.client.emit(Message("speak", metadata={
                'utterance': "I will be finished in just a moment."}))
            self.upload_hex()

        must_start_test = self.config.get('must_start_test')
        if must_start_test is not None and str2bool(must_start_test):
            ConfigurationManager.set('enclosure', 'must_start_test', False)
            time.sleep(0.5)  # Ensure arduino has booted
            self.writer.write("test.begin")
开发者ID:the7erm,项目名称:mycroft-core,代码行数:16,代码来源:enclosure.py


示例19: get

def get(phrase, lang=None, context=None):
    """
    Looks up a resource file for the given phrase.  If no file
    is found, the requested phrase is returned as the string.
    This will use the default language for translations.

    Args:
        phrase (str): resource phrase to retrieve/translate
        lang (str): the language to use
        context (dict): values to be inserted into the string

    Returns:
        str: a randomized and/or translated version of the phrase
    """

    if not lang:
        from mycroft.configuration import ConfigurationManager
        lang = ConfigurationManager.instance().get("lang")

    filename = "text/"+lang.lower()+"/"+phrase+".dialog"
    template = resolve_resource_file(filename)
    if not template:
        logger.debug("Resource file not found: " + filename)
        return phrase

    stache = MustacheDialogRenderer()
    stache.load_template_file("template", template)
    if not context:
        context = {}
    return stache.render("template", context)
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:30,代码来源:__init__.py


示例20: __init__

 def __init__(self):
     config_core = ConfigurationManager.get()
     self.lang = str(self.init_language(config_core))
     config_stt = config_core.get("stt", {})
     self.config = config_stt.get(config_stt.get("module"), {})
     self.credential = self.config.get("credential", {})
     self.recognizer = Recognizer()
开发者ID:jasonehines,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py



注:本文中的mycroft.configuration.ConfigurationManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python identity.IdentityManager类代码示例发布时间:2022-05-27
下一篇:
Python configuration.Configuration类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap