本文整理汇总了Python中mycroft.util.log.LOG类的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _load
def _load():
LOG.debug('Loading identity')
try:
with FileSystemAccess('identity').open('identity2.json', 'r') as f:
IdentityManager.__identity = DeviceIdentity(**json.load(f))
except Exception:
IdentityManager.__identity = DeviceIdentity()
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py
示例2: handle_utterance
def handle_utterance(event):
LOG.info("Utterance: " + str(event['utterances']))
context = {'client_name': 'mycroft_listener'}
if 'ident' in event:
ident = event.pop('ident')
context['ident'] = ident
bus.emit(Message('recognizer_loop:utterance', event, context))
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:7,代码来源:__main__.py
示例3: main
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,代码行数:34,代码来源:main.py
示例4: shutdown
def shutdown(self):
for s in self.service:
try:
LOG.info('shutting down ' + s.name)
s.shutdown()
except Exception as e:
LOG.error('shutdown of ' + s.name + ' failed: ' + repr(e))
# remove listeners
self.bus.remove('mycroft.audio.service.play', self._play)
self.bus.remove('mycroft.audio.service.queue', self._queue)
self.bus.remove('mycroft.audio.service.pause', self._pause)
self.bus.remove('mycroft.audio.service.resume', self._resume)
self.bus.remove('mycroft.audio.service.stop', self._stop)
self.bus.remove('mycroft.audio.service.next', self._next)
self.bus.remove('mycroft.audio.service.prev', self._prev)
self.bus.remove('mycroft.audio.service.track_info', self._track_info)
self.bus.remove('mycroft.audio.service.seek_forward',
self._seek_forward)
self.bus.remove('mycroft.audio.service.seek_backward',
self._seek_backward)
self.bus.remove('recognizer_loop:audio_output_start',
self._lower_volume)
self.bus.remove('recognizer_loop:record_begin', self._lower_volume)
self.bus.remove('recognizer_loop:audio_output_end',
self._restore_volume)
self.bus.remove('recognizer_loop:record_end', self._restore_volume)
self.bus.remove('mycroft.stop', self._stop)
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:28,代码来源:audioservice.py
示例5: load_module
def load_module(module, hotword, config, lang, loop):
LOG.info('Loading "{}" wake word via {}'.format(hotword, module))
instance = None
complete = Event()
def initialize():
nonlocal instance, complete
try:
clazz = HotWordFactory.CLASSES[module]
instance = clazz(hotword, config, lang=lang)
except TriggerReload:
complete.set()
sleep(0.5)
loop.reload()
except NoModelAvailable:
LOG.warning('Could not found find model for {} on {}.'.format(
hotword, module
))
instance = None
except Exception:
LOG.exception(
'Could not create hotword. Falling back to default.')
instance = None
complete.set()
Thread(target=initialize, daemon=True).start()
if not complete.wait(INIT_TIMEOUT):
LOG.info('{} is taking too long to load'.format(module))
complete.set()
return instance
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:30,代码来源:hotword_factory.py
示例6: _poll_skill_settings
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,代码行数:30,代码来源:settings.py
示例7: read
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,代码行数:31,代码来源:mic.py
示例8: on_gui_show_page
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,代码行数:7,代码来源:base.py
示例9: __insert_new_namespace
def __insert_new_namespace(self, namespace, pages):
""" Insert new namespace and pages.
This first sends a message adding a new namespace at the
highest priority (position 0 in the namespace stack)
Args:
namespace (str): The skill namespace to create
pages (str): Pages to insert (name matches QML)
"""
LOG.debug("Inserting new namespace")
self.send({"type": "mycroft.session.list.insert",
"namespace": "mycroft.system.active_skills",
"position": 0,
"data": [{"skill_id": namespace}]
})
# Load any already stored Data
data = self.datastore.get(namespace, {})
for key in data:
msg = {"type": "mycroft.session.set",
"namespace": namespace,
"data": {key: data[key]}}
self.send(msg)
LOG.debug("Inserting new page")
self.send({"type": "mycroft.gui.list.insert",
"namespace": namespace,
"position": 0,
"data": [{"url": p} for p in pages]
})
# Make sure the local copy is updated
self.loaded.insert(0, Namespace(namespace, pages))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:33,代码来源:base.py
示例10: on_gui_delete_page
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,代码行数:7,代码来源:base.py
示例11: on_gui_delete_namespace
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,代码行数:7,代码来源:base.py
示例12: send
def send(self, *args, **kwargs):
""" Send to all registered GUIs. """
for gui in self.GUIs.values():
if gui.socket:
gui.socket.send(*args, **kwargs)
else:
LOG.error('GUI connection {} has no socket!'.format(gui))
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:7,代码来源:base.py
示例13: simple_cli
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,代码行数:25,代码来源:text_client.py
示例14: supported_uris
def supported_uris(self):
""" Return supported uris of chromecast. """
LOG.info("Chromecasts found: " + str(self.cast))
if self.cast:
return ['http', 'https']
else:
return []
开发者ID:Dark5ide,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py
示例15: _do_net_check
def _do_net_check(self):
# TODO: This should live in the derived Enclosure, e.g. Enclosure_Mark1
LOG.info("Checking internet connection")
if not connected(): # and self.conn_monitor is None:
if has_been_paired():
# TODO: Enclosure/localization
self.speak("This unit is not connected to the Internet. "
"Either plug in a network cable or hold the "
"button on top for two seconds, then select "
"wifi from the menu")
else:
# Begin the unit startup process, this is the first time it
# is being run with factory defaults.
# TODO: This logic should be in Enclosure_Mark1
# TODO: Enclosure/localization
# Don't listen to mic during this out-of-box experience
self.ws.emit(Message("mycroft.mic.mute"))
# Setup handler to unmute mic at the end of on boarding
# i.e. after pairing is complete
self.ws.once('mycroft.paired', self._handle_pairing_complete)
self.speak(mycroft.dialog.get('mycroft.intro'))
wait_while_speaking()
time.sleep(2) # a pause sounds better than just jumping in
# Kick off wifi-setup automatically
data = {'allow_timeout': False, 'lang': self.lang}
self.ws.emit(Message('system.wifi.setup', data))
开发者ID:Ceda-EI,项目名称:mycroft-core,代码行数:30,代码来源:__init__.py
示例16: handle_converse_request
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.error(
"Converse method malformed for skill " + str(skill_id))
self.ws.emit(Message("skill.converse.response",
{"skill_id": 0, "result": False}))
开发者ID:antlarr,项目名称:mycroft-core,代码行数:30,代码来源:main.py
示例17: 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 Configuration
lang = Configuration.get().get("lang")
filename = "text/" + lang.lower() + "/" + phrase + ".dialog"
template = resolve_resource_file(filename)
if not template:
LOG.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:seymour-bootay,项目名称:mycroft-core,代码行数:30,代码来源:__init__.py
示例18: ensure_directory_exists
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,代码行数:28,代码来源:signal.py
示例19: main
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,代码行数:30,代码来源:main.py
示例20: initialize
def initialize(self):
"""
Initialization function to be implemented by all Skills.
Usually used to create intents rules and register them.
"""
LOG.debug("No initialize function implemented")
开发者ID:antlarr,项目名称:mycroft-core,代码行数:7,代码来源:core.py
注:本文中的mycroft.util.log.LOG类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论