本文整理汇总了Python中mycroft.configuration.ConfigurationManager.save方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager.save方法的具体用法?Python ConfigurationManager.save怎么用?Python ConfigurationManager.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.configuration.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from mycroft.configuration import ConfigurationManager [as 别名]
# 或者: from mycroft.configuration.ConfigurationManager import save [as 别名]
def process(self, data):
# TODO: Look into removing this emit altogether.
# We need to check if any other serial bus messages
# are handled by other parts of the code
if "mycroft.stop" not in data:
self.ws.emit(Message(data))
if "Command: system.version" in data:
# This happens in response to the "system.version" message
# sent during the construction of Enclosure()
self.ws.emit(Message("enclosure.started"))
if "mycroft.stop" in data:
if has_been_paired():
create_signal('buttonPress')
self.ws.emit(Message("mycroft.stop"))
if "volume.up" in data:
self.ws.emit(Message("mycroft.volume.increase",
{'play_sound': True}))
if "volume.down" in data:
self.ws.emit(Message("mycroft.volume.decrease",
{'play_sound': True}))
if "system.test.begin" in data:
self.ws.emit(Message('recognizer_loop:sleep'))
if "system.test.end" in data:
self.ws.emit(Message('recognizer_loop:wake_up'))
if "mic.test" in data:
mixer = Mixer()
prev_vol = mixer.getvolume()[0]
mixer.setvolume(35)
self.ws.emit(Message("speak", {
'utterance': "I am testing one two three"}))
time.sleep(0.5) # Prevents recording the loud button press
record("/tmp/test.wav", 3.0)
mixer.setvolume(prev_vol)
play_wav("/tmp/test.wav").communicate()
# Test audio muting on arduino
subprocess.call('speaker-test -P 10 -l 0 -s 1', shell=True)
if "unit.shutdown" in data:
self.ws.emit(
Message("enclosure.eyes.timedspin",
{'length': 12000}))
self.ws.emit(Message("enclosure.mouth.reset"))
subprocess.call('systemctl poweroff -i', shell=True)
if "unit.reboot" in data:
self.ws.emit(Message("enclosure.eyes.spin"))
self.ws.emit(Message("enclosure.mouth.reset"))
subprocess.call('systemctl reboot -i', shell=True)
if "unit.setwifi" in data:
self.ws.emit(Message("mycroft.wifi.start"))
if "unit.factory-reset" in data:
self.ws.emit(Message("enclosure.eyes.spin"))
subprocess.call(
'rm ~/.mycroft/identity/identity2.json',
shell=True)
self.ws.emit(Message("mycroft.wifi.reset"))
self.ws.emit(Message("mycroft.disable.ssh"))
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("reset to factory defaults")}))
wait_while_speaking()
self.ws.emit(Message("enclosure.mouth.reset"))
self.ws.emit(Message("enclosure.eyes.spin"))
self.ws.emit(Message("enclosure.mouth.reset"))
subprocess.call('systemctl reboot -i', shell=True)
if "unit.enable-ssh" in data:
# This is handled by the wifi client
self.ws.emit(Message("mycroft.enable.ssh"))
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("ssh enabled")}))
if "unit.disable-ssh" in data:
# This is handled by the wifi client
self.ws.emit(Message("mycroft.disable.ssh"))
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("ssh disabled")}))
if "unit.enable-learning" in data or "unit.disable-learning" in data:
enable = 'enable' in data
word = 'enabled' if enable else 'disabled'
LOG.info("Setting opt_in to: " + word)
new_config = {'opt_in': enable}
ConfigurationManager.save(new_config)
self.ws.emit(Message("speak", {
'utterance': mycroft.dialog.get("learning " + word)}))