我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用httplib2.__version__()。
def _set_ua_and_scopes(credentials): """Set custom Forseti user agent and add cloud scopes on credential object. Args: credentials (client.OAuth2Credentials): The credentials object used to authenticate all http requests. Returns: client.OAuth2Credentials: The credentials object with the user agent attribute set or updated. """ if isinstance(credentials, client.OAuth2Credentials): user_agent = credentials.user_agent if (not user_agent or forseti_security.__package_name__ not in user_agent): credentials.user_agent = ( 'Python-httplib2/{} (gzip), {}/{}'.format( httplib2.__version__, forseti_security.__package_name__, forseti_security.__version__)) if (isinstance(credentials, client.GoogleCredentials) and credentials.create_scoped_required()): credentials = credentials.create_scoped(list(CLOUD_SCOPES)) return credentials
def __init__(self, timeout, proxy=None, cacert=None, sessions=False): # httplib2.debuglevel=4 kwargs = {} if proxy: import socks kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy) log.info("using proxy %s" % proxy) # set optional parameters according to supported httplib2 version if httplib2.__version__ >= '0.3.0': kwargs['timeout'] = timeout if httplib2.__version__ >= '0.7.0': kwargs['disable_ssl_certificate_validation'] = cacert is None kwargs['ca_certs'] = cacert httplib2.Http.__init__(self, **kwargs)
def __init__(self, timeout, proxy=None, cacert=None, sessions=False): ##httplib2.debuglevel=4 kwargs = {} if proxy: import socks kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy) log.info("using proxy %s" % proxy) # set optional parameters according supported httplib2 version if httplib2.__version__ >= '0.3.0': kwargs['timeout'] = timeout if httplib2.__version__ >= '0.7.0': kwargs['disable_ssl_certificate_validation'] = cacert is None kwargs['ca_certs'] = cacert httplib2.Http.__init__(self, **kwargs)