当前位置: 首页>>代码示例>>Python>>正文


Python LOG.exception方法代码示例

本文整理汇总了Python中mycroft.util.log.LOG.exception方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.exception方法的具体用法?Python LOG.exception怎么用?Python LOG.exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mycroft.util.log.LOG的用法示例。


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

示例1: parse_utterances

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def parse_utterances(self, utterances, lang):
        """
            Parse the utteracne using adapt  to find a matching intent.

            Args:
                utterances (list):  list of utterances
                lang (string):      4 letter ISO language code

            Returns: Intent structure, or None if no match was found.
        """
        best_intent = None
        for utterance in utterances:
            try:
                # normalize() changes "it's a boy" to "it is boy", etc.
                best_intent = next(self.engine.determine_intent(
                    normalize(utterance, lang), 100,
                    include_tags=True,
                    context_manager=self.context_manager))
                # TODO - Should Adapt handle this?
                best_intent['utterance'] = utterance
            except StopIteration:
                # don't show error in log
                continue
            except Exception as e:
                LOG.exception(e)
                continue

        if best_intent and best_intent.get('confidence', 0.0) > 0.0:
            self.update_context(best_intent)
            # update active skills
            skill_id = int(best_intent['intent_type'].split(":")[0])
            self.add_active_skill(skill_id)
            return best_intent
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:35,代码来源:intent_service.py

示例2: handle_utterance

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def handle_utterance(self, message):
        """
            Messagebus handler for the recognizer_loop:utterance message
        """
        try:
            # Get language of the utterance
            lang = message.data.get('lang', "en-us")
            utterances = message.data.get('utterances', '')

            stopwatch = Stopwatch()
            with stopwatch:
                # Parse the sentence
                converse = self.parse_converse(utterances, lang)
                if not converse:
                    # no skill wants to handle utterance
                    intent = self.parse_utterances(utterances, lang)

            if converse:
                # Report that converse handled the intent and return
                ident = message.context['ident'] if message.context else None
                report_timing(ident, 'intent_service', stopwatch,
                              {'intent_type': 'converse'})
                return
            elif intent:
                # Send the message on to the intent handler
                reply = message.reply(intent.get('intent_type'), intent)
            else:
                # or if no match send sentence to fallback system
                reply = message.reply('intent_failure',
                                      {'utterance': utterances[0],
                                       'lang': lang})
            self.emitter.emit(reply)
            self.send_metrics(intent, message.context, stopwatch)
        except Exception as e:
            LOG.exception(e)
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:37,代码来源:intent_service.py

示例3: on_gui_delete_namespace

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
 def on_gui_delete_namespace(self, message):
     """ Bus handler for removing namespace. """
     try:
         namespace = message.data['__from']
         self.remove_namespace(namespace)
     except Exception as e:
         LOG.exception(repr(e))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:9,代码来源:base.py

示例4: handler

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
        def handler(message):
            # indicate fallback handling start
            ws.emit(Message("mycroft.skill.handler.start",
                            data={'handler': "fallback"}))

            stopwatch = Stopwatch()
            handler_name = None
            with stopwatch:
                for _, handler in sorted(cls.fallback_handlers.items(),
                                         key=operator.itemgetter(0)):
                    try:
                        if handler(message):
                            #  indicate completion
                            handler_name = get_handler_name(handler)
                            ws.emit(Message(
                                'mycroft.skill.handler.complete',
                                data={'handler': "fallback",
                                      "fallback_handler": handler_name}))
                            break
                    except Exception:
                        LOG.exception('Exception in fallback.')
                else:  # No fallback could handle the utterance
                    ws.emit(Message('complete_intent_failure'))
                    warning = "No fallback could handle intent."
                    LOG.warning(warning)
                    #  indicate completion with exception
                    ws.emit(Message('mycroft.skill.handler.complete',
                                    data={'handler': "fallback",
                                          'exception': warning}))

            # Send timing metric
            if message.context and message.context['ident']:
                ident = message.context['ident']
                report_timing(ident, 'fallback_handler', stopwatch,
                              {'handler': handler_name})
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:37,代码来源:core.py

示例5: main

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
def main():
    global ws
    global config
    ws = WebsocketClient()
    Configuration.init(ws)
    config = Configuration.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:antlarr,项目名称:mycroft-core,代码行数:32,代码来源:main.py

示例6: main

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
def main():
    global ws
    global loop
    global config
    lock = PIDLock("voice")
    ws = WebsocketClient()
    config = Configuration.get()
    Configuration.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:antlarr,项目名称:mycroft-core,代码行数:36,代码来源:main.py

示例7: _poll_skill_settings

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def _poll_skill_settings(self):
        """ If identifier exists for this skill poll to backend to
            request settings and store it if it changes
            TODO: implement as websocket

            Args:
                hashed_meta (int): the hashed identifier
        """
        try:
            if not self._complete_intialization:
                self.initialize_remote_settings()
                if not self._complete_intialization:
                    return  # unable to do remote sync
            else:
                original = hash(str(self))
                self.update_remote()
                # Call callback for updated settings
                if self.changed_callback and hash(str(self)) != original:
                    self.changed_callback()

        except Exception as e:
            LOG.error(e)
            LOG.exception("")

        # this is used in core so do not delete!
        if self.is_alive:
            # continues to poll settings every 60 seconds
            t = Timer(60, self._poll_skill_settings)
            t.daemon = True
            t.start()
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:32,代码来源:settings.py

示例8: _poll_skill_settings

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def _poll_skill_settings(self):
        """ If identifier exists for this skill poll to backend to
            request settings and store it if it changes
            TODO: implement as websocket
        """
        original = hash(str(self))
        try:
            if not is_paired():
                pass
            elif not self._complete_intialization:
                self.initialize_remote_settings()
            else:
                self.update_remote()

        except Exception as e:
            LOG.exception('Failed to fetch skill settings: {}'.format(repr(e)))
        finally:
            # Call callback for updated settings
            if self._complete_intialization:
                if self.changed_callback and hash(str(self)) != original:
                    self.changed_callback()

        if self._poll_timer:
            self._poll_timer.cancel()

        if not self._is_alive:
            return

        # continues to poll settings every minute
        self._poll_timer = Timer(1 * 60, self._poll_skill_settings)
        self._poll_timer.daemon = True
        self._poll_timer.start()
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:34,代码来源:settings.py

示例9: on_gui_show_page

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
 def on_gui_show_page(self, message):
     try:
         page, namespace, index = _get_page_data(message)
         # Pass the request to the GUI(s) to pull up a page template
         self.show(namespace, page, index)
     except Exception as e:
         LOG.exception(repr(e))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:9,代码来源:base.py

示例10: handle_converse_request

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def handle_converse_request(self, message):
        """ Check if the targeted skill id can handle conversation

        If supported, the conversation is invoked.
        """

        skill_id = int(message.data["skill_id"])
        utterances = message.data["utterances"]
        lang = message.data["lang"]

        # loop trough skills list and call converse for skill with skill_id
        for skill in self.loaded_skills:
            if self.loaded_skills[skill]["id"] == skill_id:
                try:
                    instance = self.loaded_skills[skill]["instance"]
                except BaseException:
                    LOG.error("converse requested but skill not loaded")
                    self.ws.emit(Message("skill.converse.response", {
                        "skill_id": 0, "result": False}))
                    return
                try:
                    result = instance.converse(utterances, lang)
                    self.ws.emit(Message("skill.converse.response", {
                        "skill_id": skill_id, "result": result}))
                    return
                except BaseException:
                    LOG.exception(
                        "Error in converse method for skill " + str(skill_id))
        self.ws.emit(Message("skill.converse.response",
                             {"skill_id": 0, "result": False}))
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:32,代码来源:main.py

示例11: on_gui_delete_page

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
 def on_gui_delete_page(self, message):
     """ Bus handler for removing pages. """
     page, namespace, _ = _get_page_data(message)
     try:
         self.remove_pages(namespace, page)
     except Exception as e:
         LOG.exception(repr(e))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:9,代码来源:base.py

示例12: simple_cli

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
def simple_cli():
    global bus
    global bSimple
    bSimple = True
    bus = WebsocketClient()  # Mycroft messagebus connection
    event_thread = Thread(target=connect)
    event_thread.setDaemon(True)
    event_thread.start()
    bus.on('speak', handle_speak)
    try:
        while True:
            # Sleep for a while so all the output that results
            # from the previous command finishes before we print.
            time.sleep(1.5)
            print("Input (Ctrl+C to quit):")
            line = sys.stdin.readline()
            bus.emit(Message("recognizer_loop:utterance",
                             {'utterances': [line.strip()]}))
    except KeyboardInterrupt as e:
        # User hit Ctrl+C to quit
        print("")
    except KeyboardInterrupt as e:
        LOG.exception(e)
        event_thread.exit()
        sys.exit()
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:27,代码来源:text_client.py

示例13: handle_utterance

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def handle_utterance(self, message):
        # Get language of the utterance
        lang = message.data.get('lang', None)
        if not lang:
            lang = "en-us"

        utterances = message.data.get('utterances', '')

        # check for conversation time-out
        self.active_skills = [skill for skill in self.active_skills
                              if time.time() - skill[
                                  1] <= self.converse_timeout * 60]

        # check if any skill wants to handle utterance
        for skill in self.active_skills:
            if self.do_converse(utterances, skill[0], lang):
                # update timestamp, or there will be a timeout where
                # intent stops conversing whether its being used or not
                self.add_active_skill(skill[0])
                return

        # no skill wants to handle utterance
        best_intent = None
        for utterance in utterances:
            try:
                # normalize() changes "it's a boy" to "it is boy", etc.
                best_intent = next(self.engine.determine_intent(
                    normalize(utterance, lang), 100,
                    include_tags=True,
                    context_manager=self.context_manager))
                # TODO - Should Adapt handle this?
                best_intent['utterance'] = utterance
            except StopIteration, e:
                LOG.exception(e)
                continue
开发者ID:aatchison,项目名称:mycroft-core,代码行数:37,代码来源:intent_service.py

示例14: send_skill_list

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
 def send_skill_list(self, message=None):
     """
         Send list of loaded skills.
     """
     try:
         self.ws.emit(Message('mycroft.skills.list',
                              data={'skills': self.loaded_skills.keys()}))
     except Exception as e:
         LOG.exception(e)
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:11,代码来源:main.py

示例15: on_gui_set_value

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import exception [as 别名]
    def on_gui_set_value(self, message):
        data = message.data
        namespace = data.get("__from", "")

        # Pass these values on to the GUI renderers
        for key in data:
            if key not in RESERVED_KEYS:
                try:
                    self.set(namespace, key, data[key])
                except Exception as e:
                    LOG.exception(repr(e))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:13,代码来源:base.py


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