app_identity_stub.py 文件源码

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

项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码
def Create(email_address=None, private_key_path=None, oauth_url=None):
    if email_address:
      from google.appengine.api.app_identity import app_identity_keybased_stub

      logging.debug('Using the KeyBasedAppIdentityServiceStub.')
      return app_identity_keybased_stub.KeyBasedAppIdentityServiceStub(
          email_address=email_address,
          private_key_path=private_key_path,
          oauth_url=oauth_url)
    elif sys.version_info >= (2, 6):





      import six
      if six._importer not in sys.meta_path:
        sys.meta_path.append(six._importer)
      from oauth2client import client
      from google.appengine.api.app_identity import app_identity_defaultcredentialsbased_stub as ai_stub
      try:
        dc = ai_stub.DefaultCredentialsBasedAppIdentityServiceStub()
        logging.debug('Successfully loaded Application Default Credentials.')
        return dc
      except client.ApplicationDefaultCredentialsError, error:
        if not str(error).startswith('The Application Default Credentials '
                                     'are not available.'):
          logging.warning('An exception has been encountered when attempting '
                          'to use Application Default Credentials: %s'
                          '. Falling back on dummy AppIdentityServiceStub.',
                          str(error))
        return AppIdentityServiceStub()
    else:
      logging.debug('Running under Python 2.5 uses dummy '
                    'AppIdentityServiceStub.')
      return AppIdentityServiceStub()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号