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


Python IdentityManager.load方法代码示例

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


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

示例1: check_token

# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import load [as 别名]
 def check_token(self):
     # If the identity hasn't been loaded, load it
     if not self.identity.has_refresh():
         self.identity = IdentityManager.load()
     # If refresh is needed perform a refresh
     if self.identity.refresh and self.identity.is_expired():
         self.identity = IdentityManager.load()
         # if no one else has updated the token refresh it
         if self.identity.is_expired():
             self.refresh_token()
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:12,代码来源:__init__.py

示例2: refresh_token

# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import load [as 别名]
    def refresh_token(self):
        LOG.debug('Refreshing token')
        if identity_lock.acquire(blocking=False):
            try:
                data = self.send({
                    "path": "auth/token",
                    "headers": {
                        "Authorization": "Bearer " + self.identity.refresh
                    }
                })
                IdentityManager.save(data, lock=False)
                LOG.debug('Saved credentials')
            except HTTPError as e:
                if e.response.status_code == 401:
                    LOG.error('Could not refresh token, invalid refresh code.')
                else:
                    raise

            finally:
                identity_lock.release()
        else:  # Someone is updating the identity wait for release
            with identity_lock:
                LOG.debug('Refresh is already in progress, waiting until done')
                time.sleep(1.2)
                os.sync()
                self.identity = IdentityManager.load(lock=False)
                LOG.debug('new credentials loaded')
开发者ID:MycroftAI,项目名称:mycroft-core,代码行数:29,代码来源:__init__.py

示例3: has_been_paired

# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import load [as 别名]
def has_been_paired():
    """ Determine if this device has ever been paired with a web backend

    Returns:
        bool: True if ever paired with backend (not factory reset)
    """
    # This forces a load from the identity file in case the pairing state
    # has recently changed
    id = IdentityManager.load()
    return id.uuid is not None and id.uuid != ""
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:12,代码来源:__init__.py

示例4: refresh_token

# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import load [as 别名]
 def refresh_token(self):
     LOG.debug('Refreshing token')
     if identity_lock.acquire(blocking=False):
         try:
             data = self.send({
                 "path": "auth/token",
                 "headers": {
                     "Authorization": "Bearer " + self.identity.refresh
                 }
             })
             IdentityManager.save(data, lock=False)
             LOG.debug('Saved credentials')
         finally:
             identity_lock.release()
     else:  # Someone is updating the identity wait for release
         with identity_lock:
             LOG.debug('Refresh is already in progress, waiting until done')
             time.sleep(1.2)
             os.sync()
             self.identity = IdentityManager.load(lock=False)
             LOG.debug('new credentials loaded')
开发者ID:seymour-bootay,项目名称:mycroft-core,代码行数:23,代码来源:__init__.py

示例5: check_token

# 需要导入模块: from mycroft.identity import IdentityManager [as 别名]
# 或者: from mycroft.identity.IdentityManager import load [as 别名]
 def check_token(self):
     if self.identity.refresh and self.identity.is_expired():
         self.identity = IdentityManager.load()
         if self.identity.is_expired():
             self.refresh_token()
开发者ID:ChristopherRogers1991,项目名称:mycroft-core,代码行数:7,代码来源:__init__.py


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