Skip to content
Myr

Merge pull request #4079 from kennethreitz/help

Before adoption: this commit came in with the history the project adopted, so no landing records it.

$ python -m requests.help

authored by Kenneth Reitz · committed by GitHub · parents a44284c, 0ae8524 · Browse files · 3 files+117 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+117 added−2 removed

  • other:+117 added−2 removed

3 files+117 added−2 removed

modified:requests/__version__.py+2 added-2 removed
3 unmodified lines
45__title__ = 'requests'6__description__ = 'Python HTTP for Humans.'7__url__ = 'http://python-requests.org'8__version__ = '2.16.3'9__build__ = 0x0216038__version__ = '2.16.4'9__build__ = 0x02160410__author__ = 'Kenneth Reitz'11__author_email__ = 'me@kennethreitz.org'12__license__ = 'Apache 2.0'13__copyright__ = 'Copyright 2017 Kenneth Reitz'
3 unmodified lines
added:requests/help.py+110 added
1"""Module containing bug report helper(s)."""2from __future__ import print_function34import json5import platform6import sys7import ssl89import urllib310import chardet1112from . import __version__ as requests_version1314try:15 from .packages.urllib3.contrib import pyopenssl16except ImportError:17 pyopenssl = None18 OpenSSL = None19 cryptography = None20else:21 import OpenSSL22 import cryptography232425def _implementation():26 """Return a dict with the Python implementation and verison.2728 Provide both the name and the version of the Python implementation29 currently running. For example, on CPython 2.7.5 it will return30 {'name': 'CPython', 'version': '2.7.5'}.3132 This function works best on CPython and PyPy: in particular, it probably33 doesn't work for Jython or IronPython. Future investigation should be done34 to work out the correct shape of the code for those platforms.35 """36 implementation = platform.python_implementation()3738 if implementation == 'CPython':39 implementation_version = platform.python_version()40 elif implementation == 'PyPy':41 implementation_version = '%s.%s.%s' % (sys.pypy_version_info.major,42 sys.pypy_version_info.minor,43 sys.pypy_version_info.micro)44 if sys.pypy_version_info.releaselevel != 'final':45 implementation_version = ''.join([46 implementation_version, sys.pypy_version_info.releaselevel47 ])48 elif implementation == 'Jython':49 implementation_version = platform.python_version() # Complete Guess50 elif implementation == 'IronPython':51 implementation_version = platform.python_version() # Complete Guess52 else:53 implementation_version = 'Unknown'5455 return {'name': implementation, 'version': implementation_version}565758def info():59 """Generate information for a bug report."""60 try:61 platform_info = {62 'system': platform.system(),63 'release': platform.release(),64 }65 except IOError:66 platform_info = {67 'system': 'Unknown',68 'release': 'Unknown',69 }7071 implementation_info = _implementation()72 urllib3_info = urllib3.__version__73 chardet_info = chardet.__version__7475 pyopenssl_info = {76 'version': None,77 'openssl_version': '',78 }79 if OpenSSL:80 pyopenssl_info = {81 'version': OpenSSL.__version__,82 'openssl_version': '%x' % OpenSSL.SSL.OPENSSL_VERSION_NUMBER,83 }84 cryptography_info = {85 'version': getattr(cryptography, '__version__', ''),86 }8788 return {89 'platform': platform_info,90 'implementation': implementation_info,91 'system_ssl': {92 'version': '%x' % ssl.OPENSSL_VERSION_NUMBER,93 },94 'using_pyopenssl': pyopenssl is not None,95 'pyOpenSSL': pyopenssl_info,96 'urllib3': urllib3_info,97 'chardet': chardet_info,98 'cryptography': cryptography_info,99 'requests': {100 'version': requests_version,101 },102 }103104def main():105 """Pretty-print the bug information as JSON."""106 print(json.dumps(info(), sort_keys=True, indent=2))107108if __name__ == '__main__':109 main()110
modified:HISTORY.rst+5 added
1 unmodified line
23Release History4---------------562.16.4 (2017-05-27)7+++++++++++++++++++89- Introduction of the ``$ python -m requests.help`` command, for debugging with maintainers!10112.16.3 (2017-05-27)12+++++++++++++++++++1314- Further restored the ``requests.packages`` namespace for compatibility reasons.
1419 unmodified lines