當前位置: 首頁>>代碼示例>>Python>>正文


Python request.getproxies_environment方法代碼示例

本文整理匯總了Python中urllib.request.getproxies_environment方法的典型用法代碼示例。如果您正苦於以下問題:Python request.getproxies_environment方法的具體用法?Python request.getproxies_environment怎麽用?Python request.getproxies_environment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib.request的用法示例。


在下文中一共展示了request.getproxies_environment方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import getproxies_environment [as 別名]
def __init__(self, service, operation, region_name, endpoint_url=None, session=None,
                 connect_timeout=None, request_timeout=None):
        # set credentials manually
        session = session or botocore.session.get_session()
        # get_session accepts access_key, secret_key
        self.client = session.create_client(
            service,
            region_name=region_name,
            endpoint_url=endpoint_url
        )
        try:
            self.endpoint = self.client.endpoint
        except AttributeError:
            self.endpoint = self.client._endpoint

        self.operation = operation
        self.http_client = AsyncHTTPClient()

        self.proxy_host = None
        self.proxy_port = None
        https_proxy = getproxies_environment().get('https')
        if https_proxy:
            self._enable_curl_httpclient()

            proxy_parts = https_proxy.split(':')
            if len(proxy_parts) == 2 and proxy_parts[-1].isdigit():
                self.proxy_host, self.proxy_port = proxy_parts
                self.proxy_port = int(self.proxy_port)
            else:
                proxy = urlparse(https_proxy)
                self.proxy_host = proxy.hostname
                self.proxy_port = proxy.port

        self.request_timeout = request_timeout
        self.connect_timeout = connect_timeout 
開發者ID:nanvel,項目名稱:tornado-botocore,代碼行數:37,代碼來源:base.py

示例2: proxied

# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import getproxies_environment [as 別名]
def proxied(value):
    netloc = urlparse(value).netloc
    proxied = bool(getproxies_environment()) and not proxy_bypass(netloc)
    return(proxied) 
開發者ID:oVirt,項目名稱:ovirt-ansible-hosted-engine-setup,代碼行數:6,代碼來源:ovirt_proxied_check.py


注:本文中的urllib.request.getproxies_environment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。