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


Python IdentityManager.get方法代码示例

本文整理汇总了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()
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:9,代码来源:__init__.py

示例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()
开发者ID:antlarr,项目名称:mycroft-core,代码行数:12,代码来源:__init__.py

示例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()
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:15,代码来源:__init__.py

示例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()
开发者ID:UberPanda,项目名称:mycroft-core,代码行数:45,代码来源:client.py


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