Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/urllib3/__init__.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
| author | shellac |
|---|---|
| date | Mon, 01 Jun 2020 08:59:25 -0400 |
| parents | 79f47841a781 |
| children |
comparison
equal
deleted
inserted
replaced
| 4:79f47841a781 | 5:9b1c78e6ba9c |
|---|---|
| 1 """ | |
| 2 urllib3 - Thread-safe connection pooling and re-using. | |
| 3 """ | |
| 4 from __future__ import absolute_import | |
| 5 import warnings | |
| 6 | |
| 7 from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url | |
| 8 | |
| 9 from . import exceptions | |
| 10 from .filepost import encode_multipart_formdata | |
| 11 from .poolmanager import PoolManager, ProxyManager, proxy_from_url | |
| 12 from .response import HTTPResponse | |
| 13 from .util.request import make_headers | |
| 14 from .util.url import get_host | |
| 15 from .util.timeout import Timeout | |
| 16 from .util.retry import Retry | |
| 17 | |
| 18 | |
| 19 # Set default logging handler to avoid "No handler found" warnings. | |
| 20 import logging | |
| 21 from logging import NullHandler | |
| 22 | |
| 23 __author__ = "Andrey Petrov (andrey.petrov@shazow.net)" | |
| 24 __license__ = "MIT" | |
| 25 __version__ = "1.25.9" | |
| 26 | |
| 27 __all__ = ( | |
| 28 "HTTPConnectionPool", | |
| 29 "HTTPSConnectionPool", | |
| 30 "PoolManager", | |
| 31 "ProxyManager", | |
| 32 "HTTPResponse", | |
| 33 "Retry", | |
| 34 "Timeout", | |
| 35 "add_stderr_logger", | |
| 36 "connection_from_url", | |
| 37 "disable_warnings", | |
| 38 "encode_multipart_formdata", | |
| 39 "get_host", | |
| 40 "make_headers", | |
| 41 "proxy_from_url", | |
| 42 ) | |
| 43 | |
| 44 logging.getLogger(__name__).addHandler(NullHandler()) | |
| 45 | |
| 46 | |
| 47 def add_stderr_logger(level=logging.DEBUG): | |
| 48 """ | |
| 49 Helper for quickly adding a StreamHandler to the logger. Useful for | |
| 50 debugging. | |
| 51 | |
| 52 Returns the handler after adding it. | |
| 53 """ | |
| 54 # This method needs to be in this __init__.py to get the __name__ correct | |
| 55 # even if urllib3 is vendored within another package. | |
| 56 logger = logging.getLogger(__name__) | |
| 57 handler = logging.StreamHandler() | |
| 58 handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(message)s")) | |
| 59 logger.addHandler(handler) | |
| 60 logger.setLevel(level) | |
| 61 logger.debug("Added a stderr logging handler to logger: %s", __name__) | |
| 62 return handler | |
| 63 | |
| 64 | |
| 65 # ... Clean up. | |
| 66 del NullHandler | |
| 67 | |
| 68 | |
| 69 # All warning filters *must* be appended unless you're really certain that they | |
| 70 # shouldn't be: otherwise, it's very hard for users to use most Python | |
| 71 # mechanisms to silence them. | |
| 72 # SecurityWarning's always go off by default. | |
| 73 warnings.simplefilter("always", exceptions.SecurityWarning, append=True) | |
| 74 # SubjectAltNameWarning's should go off once per host | |
| 75 warnings.simplefilter("default", exceptions.SubjectAltNameWarning, append=True) | |
| 76 # InsecurePlatformWarning's don't vary between requests, so we keep it default. | |
| 77 warnings.simplefilter("default", exceptions.InsecurePlatformWarning, append=True) | |
| 78 # SNIMissingWarnings should go off only once. | |
| 79 warnings.simplefilter("default", exceptions.SNIMissingWarning, append=True) | |
| 80 | |
| 81 | |
| 82 def disable_warnings(category=exceptions.HTTPWarning): | |
| 83 """ | |
| 84 Helper for quickly disabling all urllib3 warnings. | |
| 85 """ | |
| 86 warnings.simplefilter("ignore", category) |
