本文整理汇总了Python中mycroft.identity.IdentityManager.get方法的典型用法代码示例。如果您正苦于以下问题:Python IdentityManager.get方法的具体用法?Python IdentityManager.get怎么用?Python IdentityManager.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mycroft.identity.IdentityManager
的用法示例。
在下文中一共展示了IdentityManager.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import get [as 别名]
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()
示例2: __init__
# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import get [as 别名]
def __init__(self, path):
self.path = path
config = Configuration.get([LocalConf(DEFAULT_CONFIG),
LocalConf(SYSTEM_CONFIG),
LocalConf(USER_CONFIG)],
cache=False)
config_server = config.get("server")
self.url = config_server.get("url")
self.version = config_server.get("version")
self.identity = IdentityManager.get()
示例3: __init__
# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import get [as 别名]
def __init__(self, path):
self.path = path
# Load the config, skipping the REMOTE_CONFIG since we are
# getting the info needed to get to it!
config = Configuration.get([DEFAULT_CONFIG,
SYSTEM_CONFIG,
USER_CONFIG],
cache=False)
config_server = config.get("server")
self.url = config_server.get("url")
self.version = config_server.get("version")
self.identity = IdentityManager.get()
示例4: DevicePairingClient
# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import get [as 别名]
class DevicePairingClient(object):
def __init__(self, config=_config, pairing_code=None):
self.config = config
self.paired = False
self.ws_client = WebsocketClient(host=config.get("host"),
port=config.get("port"),
path=config.get("route"),
ssl=str2bool(config.get("ssl")))
self.identity_manager = IdentityManager()
self.identity = self.identity_manager.identity
self.pairing_code = (
pairing_code if pairing_code else generate_pairing_code())
def on_registration(self, message):
# TODO: actually accept the configuration message and store it in
# identity
identity = self.identity_manager.get()
register_payload = message.metadata
if register_payload.get("device_id") == identity.device_id:
identity.token = register_payload.get('token')
identity.owner = register_payload.get('user')
self.identity_manager.update(identity)
self.ws_client.close()
self.paired = True
def send_device_info(self):
msg = Message("device_info",
metadata={
"pairing_code": self.pairing_code,
"device_id": self.identity.device_id
})
self.ws_client.emit(msg)
@staticmethod
def print_error(message):
print(repr(message))
def run(self):
self.ws_client.on('registration', self.on_registration)
self.ws_client.on('open', self.send_device_info)
self.ws_client.on('error', self.print_error)
self.ws_client.run_forever()