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


Python LOG.warning方法代码示例

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


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

示例1: process

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def process(self, audio):
        SessionManager.touch()
        payload = {
            'utterance': self.wakeword_recognizer.key_phrase,
            'session': SessionManager.get().session_id,
        }
        self.emitter.emit("recognizer_loop:wakeword", payload)

        if self._audio_length(audio) < self.MIN_AUDIO_SIZE:
            LOG.warning("Audio too short to be processed")
        else:
            stopwatch = Stopwatch()
            with stopwatch:
                transcription = self.transcribe(audio)
            if transcription:
                ident = str(stopwatch.timestamp) + str(hash(transcription))
                # STT succeeded, send the transcribed speech on for processing
                payload = {
                    'utterances': [transcription],
                    'lang': self.stt.lang,
                    'session': SessionManager.get().session_id,
                    'ident': ident
                }
                self.emitter.emit("recognizer_loop:utterance", payload)
                self.metrics.attr('utterances', [transcription])
            else:
                ident = str(stopwatch.timestamp)
            # Report timing metrics
            report_timing(ident, 'stt', stopwatch,
                          {'transcription': transcription,
                           'stt': self.stt.__class__.__name__})
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:33,代码来源:listener.py

示例2: handler

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [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

示例3: __init__

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    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,代码行数:33,代码来源:padatious_service.py

示例4: transcribe

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
 def transcribe(self, audio):
     text = None
     try:
         # Invoke the STT engine on the audio clip
         text = self.stt.execute(audio).lower().strip()
         LOG.debug("STT: " + text)
     except sr.RequestError as e:
         LOG.error("Could not request Speech Recognition {0}".format(e))
     except ConnectionError as e:
         LOG.error("Connection Error: {0}".format(e))
         self.emitter.emit("recognizer_loop:no_internet")
     except HTTPError as e:
         if e.response.status_code == 401:
             text = "pair my device"  # phrase to start the pairing process
             LOG.warning("Access Denied at mycroft.ai")
     except Exception as e:
         LOG.error(e)
         LOG.error("Speech Recognition could not understand audio")
     if text:
         # STT succeeded, send the transcribed speech on for processing
         payload = {
             'utterances': [text],
             'lang': self.stt.lang,
             'session': SessionManager.get().session_id
         }
         self.emitter.emit("recognizer_loop:utterance", payload)
         self.metrics.attr('utterances', [text])
开发者ID:aatchison,项目名称:mycroft-core,代码行数:29,代码来源:listener.py

示例5: ensure_directory_exists

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
def ensure_directory_exists(directory, domain=None):
    """ Create a directory and give access rights to all

    Args:
        domain (str): The IPC domain.  Basically a subdirectory to prevent
            overlapping signal filenames.

    Returns:
        str: a path to the directory
    """
    if domain:
        directory = os.path.join(directory, domain)

    # Expand and normalize the path
    directory = os.path.normpath(directory)
    directory = os.path.expanduser(directory)

    if not os.path.isdir(directory):
        try:
            save = os.umask(0)
            os.makedirs(directory, 0o777)  # give everyone rights to r/w here
        except OSError:
            LOG.warning("Failed to create: " + directory)
            pass
        finally:
            os.umask(save)

    return directory
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:30,代码来源:signal.py

示例6: read

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def read(self, size, of_exc=False):
        """
            Read data from stream.

            Arguments:
                size (int): Number of bytes to read
                of_exc (bool): flag determining if the audio producer thread
                               should throw IOError at overflows.

            Returns:
                Data read from device
        """
        frames = collections.deque()
        remaining = size
        while remaining > 0:
            to_read = min(self.wrapped_stream.get_read_available(), remaining)
            if to_read == 0:
                sleep(.01)
                continue
            result = self.wrapped_stream.read(to_read,
                                              exception_on_overflow=of_exc)
            frames.append(result)
            remaining -= to_read

        if self.muted:
            return self.muted_buffer
        input_latency = self.wrapped_stream.get_input_latency()
        if input_latency > 0.2:
            LOG.warning("High input latency: %f" % input_latency)
        audio = b"".join(list(frames))
        return audio
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:33,代码来源:mic.py

示例7: transcribe

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def transcribe(self, audio):
        try:
            # Invoke the STT engine on the audio clip
            text = self.stt.execute(audio).lower().strip()
            LOG.debug("STT: " + text)
            return text
        except sr.RequestError as e:
            LOG.error("Could not request Speech Recognition {0}".format(e))
        except ConnectionError as e:
            LOG.error("Connection Error: {0}".format(e))

            self.emitter.emit("recognizer_loop:no_internet")
        except HTTPError as e:
            if e.response.status_code == 401:
                LOG.warning("Access Denied at mycroft.ai")
                return "pair my device"  # phrase to start the pairing process
            else:
                LOG.error(e.__class__.__name__ + ': ' + str(e))
        except RequestException as e:
            LOG.error(e.__class__.__name__ + ': ' + str(e))
        except Exception as e:
            self.emitter.emit('recognizer_loop:speech.recognition.unknown')
            if isinstance(e, IndexError):
                LOG.info('no words were transcribed')
            else:
                LOG.error(e)
            LOG.error("Speech Recognition could not understand audio")
            return None
        if connected():
            dialog_name = 'backend.down'
        else:
            dialog_name = 'not connected to the internet'
        self.emitter.emit('speak', {'utterance': dialog.get(dialog_name)})
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:35,代码来源:listener.py

示例8: callback_disconnect

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
 def callback_disconnect(self, gui_id):
     LOG.info("Disconnecting!")
     # TODO: Whatever is needed to kill the websocket instance
     LOG.info(self.GUIs.keys())
     LOG.info('deleting: {}'.format(gui_id))
     if gui_id in self.GUIs:
         del self.GUIs[gui_id]
     else:
         LOG.warning('ID doesn\'t exist')
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:11,代码来源:base.py

示例9: on_error

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
 def on_error(self, ws, error):
     try:
         self.emitter.emit('error', error)
         self.client.close()
     except Exception as e:
         LOG.error(repr(e))
     LOG.warning("WS Client will reconnect in %d seconds." % self.retry)
     time.sleep(self.retry)
     self.retry = min(self.retry * 2, 60)
     self.client = self.create_client()
     self.run_forever()
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:13,代码来源:ws.py

示例10: load_skill

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
def load_skill(skill_descriptor, emitter, skill_id, BLACKLISTED_SKILLS=None):
    """
        load skill from skill descriptor.

        Args:
            skill_descriptor: descriptor of skill to load
            emitter:          messagebus emitter
            skill_id:         id number for skill
        Returns:
            MycroftSkill: the loaded skill or None on failure
    """
    BLACKLISTED_SKILLS = BLACKLISTED_SKILLS or []
    try:
        LOG.info("ATTEMPTING TO LOAD SKILL: " + skill_descriptor["name"] +
                 " with ID " + str(skill_id))
        if skill_descriptor['name'] in BLACKLISTED_SKILLS:
            LOG.info("SKILL IS BLACKLISTED " + skill_descriptor["name"])
            return None
        skill_module = imp.load_module(
            skill_descriptor["name"] + MainModule, *skill_descriptor["info"])
        if (hasattr(skill_module, 'create_skill') and
                callable(skill_module.create_skill)):
            # v2 skills framework
            skill = skill_module.create_skill()
            skill.settings.allow_overwrite = True
            skill.settings.load_skill_settings_from_file()
            skill.bind(emitter)
            skill.skill_id = skill_id
            skill.load_data_files(dirname(skill_descriptor['info'][1]))
            # Set up intent handlers
            skill.initialize()
            skill._register_decorated()
            LOG.info("Loaded " + skill_descriptor["name"])

            # The very first time a skill is run, speak the intro
            first_run = skill.settings.get("__mycroft_skill_firstrun", True)
            if first_run:
                LOG.info("First run of "+skill_descriptor["name"])
                skill.settings["__mycroft_skill_firstrun"] = False
                skill.settings.store()
                intro = skill.get_intro_message()
                if intro:
                    skill.speak(intro)
            return skill
        else:
            LOG.warning(
                "Module %s does not appear to be skill" % (
                    skill_descriptor["name"]))
    except:
        LOG.error(
            "Failed to load skill: " + skill_descriptor["name"],
            exc_info=True)
    return None
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:55,代码来源:core.py

示例11: process

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def process(self, audio):
        SessionManager.touch()
        payload = {
            'utterance': self.wakeword_recognizer.key_phrase,
            'session': SessionManager.get().session_id,
        }
        self.emitter.emit("recognizer_loop:wakeword", payload)

        if self._audio_length(audio) < self.MIN_AUDIO_SIZE:
            LOG.warning("Audio too short to be processed")
        else:
            self.transcribe(audio)
开发者ID:aatchison,项目名称:mycroft-core,代码行数:14,代码来源:listener.py

示例12: remove_fallback

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def remove_fallback(cls, handler_to_del):
        """
            Remove a fallback handler

            Args:
                handler_to_del: reference to handler
        """
        for priority, handler in cls.fallback_handlers.items():
            if handler == handler_to_del:
                del cls.fallback_handlers[priority]
                return
        LOG.warning('Could not remove fallback!')
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:14,代码来源:core.py

示例13: _register_object

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def _register_object(self, message, object_name, register_func):
        file_name = message.data['file_name']
        name = message.data['name']

        LOG.debug('Registering Padatious ' + object_name + ': ' + name)

        if not isfile(file_name):
            LOG.warning('Could not find file ' + file_name)
            return

        register_func(name, file_name)
        self.train_time = get_time() + self.train_delay
        self.wait_and_train()
开发者ID:aatchison,项目名称:mycroft-core,代码行数:15,代码来源:padatious_service.py

示例14: _load_or_reload_skill

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
    def _load_or_reload_skill(self, skill_folder):
        """
            Check if unloaded skill or changed skill needs reloading
            and perform loading if necessary.
        """
        if skill_folder not in self.loaded_skills:
            self.loaded_skills[skill_folder] = {
                "id": hash(os.path.join(SKILLS_DIR, skill_folder))
            }
        skill = self.loaded_skills.get(skill_folder)
        skill["path"] = os.path.join(SKILLS_DIR, skill_folder)

        # check if folder is a skill (must have __init__.py)
        if not MainModule + ".py" in os.listdir(skill["path"]):
            return

        # getting the newest modified date of skill
        modified = _get_last_modified_date(skill["path"])
        last_mod = skill.get("last_modified", 0)

        # checking if skill is loaded and wasn't modified
        if skill.get("loaded") and modified <= last_mod:
            return

        # check if skill was modified
        elif skill.get("instance") and modified > last_mod:
            # check if skill is allowed to reloaded
            if not skill["instance"].reload_skill:
                return
            LOG.debug("Reloading Skill: " + skill_folder)
            # removing listeners and stopping threads
            skill["instance"].shutdown()

            # Remove two local references that are known
            refs = sys.getrefcount(skill["instance"]) - 2
            if refs > 0:
                LOG.warning(
                    "After shutdown of {} there are still "
                    "{} references remaining. The skill "
                    "won't be cleaned from memory."
                    .format(skill['instance'].name, refs))
            del skill["instance"]

        # (Re)load the skill from disk
        with self.__msm_lock:  # Make sure msm isn't running
            skill["loaded"] = True
            desc = create_skill_descriptor(skill["path"])
            skill["instance"] = load_skill(desc,
                                           self.ws, skill["id"],
                                           BLACKLISTED_SKILLS)
            skill["last_modified"] = modified
开发者ID:antlarr,项目名称:mycroft-core,代码行数:53,代码来源:main.py

示例15: read

# 需要导入模块: from mycroft.util.log import LOG [as 别名]
# 或者: from mycroft.util.log.LOG import warning [as 别名]
 def read(self):
     while self.alive:
         try:
             data = self.serial.readline()[:-2]
             if data:
                 try:
                     data_str = data.decode()
                 except UnicodeError as e:
                     data_str = data.decode('utf-8', errors='replace')
                     LOG.warning('Invalid characters in response from '
                                 ' enclosure: {}'.format(repr(e)))
                 self.process(data_str)
         except Exception as e:
             LOG.error("Reading error: {0}".format(e))
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:16,代码来源:__init__.py


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