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


Python urllib3.__version__方法代碼示例

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


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

示例1: systemInfo

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def systemInfo():
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    return OrderedDict([
        ('platform', platform_info),
        ('interpreter', _pythonVersion()),
        ('cloudscraper', cloudscraper_version),
        ('requests', requests.__version__),
        ('urllib3', urllib3.__version__),
        ('OpenSSL', OrderedDict(
            [
                ('version', ssl.OPENSSL_VERSION),
                ('ciphers', getPossibleCiphers())
            ]
        ))
    ])

# ------------------------------------------------------------------------------- # 
開發者ID:a4k-openproject,項目名稱:a4kScrapers,代碼行數:29,代碼來源:help.py

示例2: _urllib3_fix_filenames

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def _urllib3_fix_filenames(kwargs):
    """
    Remove non-ASCII characters from file names due to a limitation of the combination of
    urllib3 (via python-requests) and our server
    https://github.com/requests/requests/issues/2117
    Internal Ticket #3090
    """

    import urllib3

    # fixed in urllib3 1.25.2
    # https://github.com/urllib3/urllib3/pull/1492
    try:
        urllib_version = [int(p) for p in urllib3.__version__.split(".")]
    except Exception:
        print("Error parsing urllib version: " + urllib3.__version__, file=sys.stderr)
        return

    if urllib_version >= [1, 25, 2]:
        return

    if "files" in kwargs and kwargs["files"] is not None:
        acceptable_chars = "0123456789" + "abcdefghijklmnopqrstuvwxyz" + \
                           "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + " _-.,()[]{}"
        for param_name, fp in kwargs["files"].items():
            if isinstance(fp, (tuple, list)):
                filename, fp = fp
            else:
                filename = requests.utils.guess_filename(fp) or param_name

            def encode(char):
                try:
                    if char in acceptable_chars:
                        return char
                except UnicodeDecodeError:
                    pass
                return "x{:02x}".format(ord(char))
            filename = "".join(encode(x) for x in filename)

            kwargs["files"][param_name] = (filename, fp) 
開發者ID:joesecurity,項目名稱:jbxapi,代碼行數:42,代碼來源:jbxapi.py

示例3: print_ver_info

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def print_ver_info():
    print('python-telegram-bot {0}'.format(telegram_ver))
    print('urllib3 {0}'.format(urllib3.__version__))
    print('certifi {0}'.format(certifi.__version__))
    print('future {0}'.format(future.__version__))
    print('Python {0}'.format(sys.version.replace('\n', ' '))) 
開發者ID:gorgiaxx,項目名稱:qprotocal,代碼行數:8,代碼來源:__main__.py

示例4: __init__

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def __init__(self, token, endpoint=constants.DEFAULT_STREAM_ENDPOINT,
                 timeout=constants.DEFAULT_TIMEOUT, compress=True,
                 proxy_url=None):
        super(SSETransport, self).__init__(token, endpoint, timeout)
        pool_args = {
            'url': self._endpoint,
            'headers': {
                'Content-Type': 'text/plain',
                'X-SF-Token': self._token,
                'User-Agent': '{} urllib3/{}'.format(version.user_agent,
                                                     urllib3.__version__)
            },
            'timeout': urllib3.Timeout(connect=self._timeout, read=None),
        }

        if urllib3.util.parse_url(self._endpoint).scheme == 'https':
            pool_args.update({
                'cert_reqs': 'CERT_REQUIRED',  # Force certificate check.
                'ca_certs': certifi.where()    # Path to the Certifi bundle.
            })

        if proxy_url:
            proxy_manager = urllib3.poolmanager.proxy_from_url(proxy_url)
            endpoint = pool_args.pop('url')
            self._http = proxy_manager.connection_from_url(
                    endpoint, pool_kwargs=pool_args)
        else:
            self._http = urllib3.connectionpool.connection_from_url(
                    **pool_args) 
開發者ID:signalfx,項目名稱:signalfx-python,代碼行數:31,代碼來源:sse.py

示例5: info

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def info():
    """Generate information for a bug report."""
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    implementation_info = _implementation()
    urllib3_info = {'version': urllib3.__version__}
    chardet_info = {'version': chardet.__version__}

    pyopenssl_info = {
        'version': None,
        'openssl_version': '',
    }
    if OpenSSL:
        pyopenssl_info = {
            'version': OpenSSL.__version__,
            'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER,
        }
    cryptography_info = {
        'version': getattr(cryptography, '__version__', ''),
    }
    idna_info = {
        'version': getattr(idna, '__version__', ''),
    }

    system_ssl = ssl.OPENSSL_VERSION_NUMBER
    system_ssl_info = {
        'version': '%x' % system_ssl if system_ssl is not None else ''
    }

    return {
        'platform': platform_info,
        'implementation': implementation_info,
        'system_ssl': system_ssl_info,
        'using_pyopenssl': pyopenssl is not None,
        'pyOpenSSL': pyopenssl_info,
        'urllib3': urllib3_info,
        'chardet': chardet_info,
        'cryptography': cryptography_info,
        'idna': idna_info,
        'requests': {
            'version': requests_version,
        },
    } 
開發者ID:danielecook,項目名稱:gist-alfred,代碼行數:54,代碼來源:help.py

示例6: info

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def info():
    """Generate information for a bug report."""
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    implementation_info = _implementation()
    urllib3_info = {'version': urllib3.__version__}
    chardet_info = {'version': chardet.__version__}

    pyopenssl_info = {
        'version': None,
        'openssl_version': '',
    }
    if OpenSSL:
        pyopenssl_info = {
            'version': OpenSSL.__version__,
            'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER,
        }
    cryptography_info = {
        'version': getattr(cryptography, '__version__', ''),
    }
    idna_info = {
        'version': getattr(idna, '__version__', ''),
    }

    # OPENSSL_VERSION_NUMBER doesn't exist in the Python 2.6 ssl module.
    system_ssl = getattr(ssl, 'OPENSSL_VERSION_NUMBER', None)
    system_ssl_info = {
        'version': '%x' % system_ssl if system_ssl is not None else ''
    }

    return {
        'platform': platform_info,
        'implementation': implementation_info,
        'system_ssl': system_ssl_info,
        'using_pyopenssl': pyopenssl is not None,
        'pyOpenSSL': pyopenssl_info,
        'urllib3': urllib3_info,
        'chardet': chardet_info,
        'cryptography': cryptography_info,
        'idna': idna_info,
        'requests': {
            'version': requests_version,
        },
    } 
開發者ID:MarcelloLins,項目名稱:ServerlessCrawler-VancouverRealState,代碼行數:55,代碼來源:help.py

示例7: info

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def info():
    """Generate information for a bug report."""
    try:
        platform_info = {
            'system': platform.system(),
            'release': platform.release(),
        }
    except IOError:
        platform_info = {
            'system': 'Unknown',
            'release': 'Unknown',
        }

    implementation_info = _implementation()
    urllib3_info = {'version': urllib3.__version__}
    chardet_info = {'version': chardet.__version__}

    pyopenssl_info = {
        'version': None,
        'openssl_version': '',
    }
    if OpenSSL:
        pyopenssl_info = {
            'version': OpenSSL.__version__,
            'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER,
        }
    cryptography_info = {
        'version': getattr(cryptography, '__version__', ''),
    }

    return {
        'platform': platform_info,
        'implementation': implementation_info,
        'system_ssl': {
            'version': '%x' % ssl.OPENSSL_VERSION_NUMBER,
        },
        'using_pyopenssl': pyopenssl is not None,
        'pyOpenSSL': pyopenssl_info,
        'urllib3': urllib3_info,
        'chardet': chardet_info,
        'cryptography': cryptography_info,
        'requests': {
            'version': requests_version,
        },
    } 
開發者ID:kuhnertdm,項目名稱:wow-addon-updater,代碼行數:47,代碼來源:help.py

示例8: __init__

# 需要導入模塊: import urllib3 [as 別名]
# 或者: from urllib3 import __version__ [as 別名]
def __init__(self, apikey=None, apiurl=None, accept_tac=None,
                       timeout=None, verify_ssl=True, retries=3,
                       proxies=None, user_agent=None):
        """
        Create a JoeSandbox object.

        Parameters:
          apikey:     the api key
          apiurl:     the api url
          accept_tac: Joe Sandbox Cloud requires accepting the Terms and Conditions.
                      https://jbxcloud.joesecurity.org/resources/termsandconditions.pdf
          timeout:    Timeout in seconds for accessing the API. Raises a ConnectionError on timeout.
          verify_ssl: Enable or disable checking SSL certificates.
          retries:    Number of times requests should be retried if they timeout.
          proxies:    Proxy settings, see the requests library for more information:
                      http://docs.python-requests.org/en/master/user/advanced/#proxies
          user_agent: The user agent. Use this when you write an integration with Joe Sandbox
                      so that it is possible to track how often an integration is being used.
        """

        if apikey is None:
            apikey = os.environ.get("JBX_API_KEY", API_KEY)

        if apiurl is None:
            apiurl = os.environ.get("JBX_API_URL", API_URL)

        if accept_tac is None:
            if "JBX_ACCEPT_TAC" in os.environ:
                accept_tac = os.environ.get("JBX_ACCEPT_TAC") == "1"
            else:
                accept_tac = ACCEPT_TAC

        self.apikey = apikey
        self.apiurl = apiurl.rstrip("/")
        self.accept_tac = accept_tac
        self.timeout = timeout
        self.retries = retries

        if user_agent:
            user_agent += " (jbxapi.py {})".format(__version__)
        else:
            user_agent = "jbxapi.py {}".format(__version__)

        self.session = requests.Session()
        self.session.verify = verify_ssl
        self.session.proxies = proxies
        self.session.headers.update({"User-Agent": user_agent}) 
開發者ID:joesecurity,項目名稱:jbxapi,代碼行數:49,代碼來源:jbxapi.py


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