Skip to content

Instantly share code, notes, and snippets.

@t-8ch
Last active August 29, 2015 14:01
Show Gist options
  • Save t-8ch/4ecfd78a502b7a616028 to your computer and use it in GitHub Desktop.
Save t-8ch/4ecfd78a502b7a616028 to your computer and use it in GitHub Desktop.
Show debug info for python-requests
#!/usr/bin/env python
from __future__ import print_function
import pkg_resources
import platform
import requests
def get_version(package):
pkg = pkg_resources.working_set.by_key.get(package)
if pkg is None:
return None
else:
return pkg.version
# may change in the future
if hasattr(requests, 'pyopenssl'):
ssl_backend = 'pyopenssl'
else:
ssl_backend = 'stdlib'
requests_version = get_version('requests')
pyopenssl_version = get_version('pyopenssl')
pyasn1_version = get_version('pyasn1')
httpsclient_version = get_version('ndg-httpsclient')
platform_info = platform.platform()
interpreter = ' '.join((platform.python_implementation(),
platform.python_version()))
print('Platform: ', platform_info)
print('Interpreter: ', interpreter)
print()
print('Versions:')
print('requests: ', requests_version)
print('pyopenssl: ', pyopenssl_version)
print('pyasn1: ', pyasn1_version)
print('ndg-httpsclient:', httpsclient_version)
print()
print('SSL backend:', ssl_backend)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment