profile.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:concorde 作者: frutiger 项目源码 文件源码
def _check_or_add_account(self):
        if 'account' in self._config:
            account = self._config['account']
            with open(account['key'], 'rb') as f:
                data = f.read()

            if account['key_type'] == 'raw':
                key = data
            elif account['key_type'] == 'pem':
                key = serialization.load_pem_private_key(data, None, backend)
            elif account['key_type'] == 'der':
                key = serialization.load_der_private_key(data, None, backend)
            else:
                raise RuntimeError('Unknown key type: ' + account['key_type'])

            registration = account['registration']
        else:
            registration, key = self._add_account()

        links, account = self._client.registration(key, registration)
        agreement = links.get('terms-of-service', {}).get('url')
        if account.get('agreement') != agreement:
            self._log('account: accepting {} in 5 seconds...',
                      agreement,
                      level=logging.WARN)
            time.sleep(5)
            self._client.registration(key, registration, agreement)
            self._log('account: done')

        return key
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号