gce.py 文件源码

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

项目:metrics 作者: Jeremy-Friedman 项目源码 文件源码
def _get_service_account_email(http_request=None):
    """Get the GCE service account email from the current environment.

    Args:
        http_request: callable, (Optional) a callable that matches the method
                      signature of httplib2.Http.request, used to make
                      the request to the metadata service.

    Returns:
        tuple, A pair where the first entry is an optional response (from a
        failed request) and the second is service account email found (as
        a string).
    """
    if http_request is None:
        http_request = httplib2.Http().request
    response, content = http_request(
        _DEFAULT_EMAIL_METADATA, headers={'Metadata-Flavor': 'Google'})
    if response.status == http_client.OK:
        content = _from_bytes(content)
        return None, content
    else:
        return response, content
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号