Skip to content

mastropinguino/pyinfo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyinfo

This library collect all the info for python environment you are running and optionally display them as html page or on terminal for cli program. It could be considered like a python equivalent of phpinfo for php language.

Usage as standalone command

$ python -m pyinfo
============== System information ==============
     Python version: 3.6.3
         OS Version: Linux 4.13.11-1-ARCH
         Executable: /usr/bin/python3
         Build Date: Oct 24 2017 14:48:20
           Compiler: GCC 7.2.0
         Python API: 1013
...

Usage via python code

import pyinfo

# get the information as object
info = pyinfo.python_info()

# The info dictionary contains all info grouped by topic
# info = {
#    'System information': { ... },
#    'Python internals': { ... },
#    'OS internals': { ... },
#    'Environment variables': { ... },
#    'Database support': { ... },
#    'Compression and archiving': { ... },
#    'Socket': { ... },
#    'Multimedia support': { ... },
#    'Copyright'
# }

print(info['Socket']['Hostname'])
# > 3.6.3


# you can even retrieve the text or html versions
text_info = pyinfo.info_as_text()
print(text_info)

with open('/tmp/pyinfo.html', 'w') as f:
    f.write(pyinfo.info_as_html())

As standalone WSGI app

def application(environ, start_response):
    import pyinfo

    output = pyinfo.info_as_html()

    start_response('200 OK', [('Content-type', 'text/html')])
    return [output]

or using a wsgi capable webserver like gunicorn:

$ gunicorn pyinfo.wsgi

Mount into WSGI application

Eg. using flask

# flask_example.py

from flask import Flask

app = Flask(__name__)


@app.route('/pyinfo')
def info():
    import pyinfo
    return pyinfo.info_as_html()

Even with webapp2

# webapp2_example.py

from webapp2 import Route, WSGIApplication

APP = WSGIApplication([
    Route('/pyinfo', handler='pyinfo.wsgi.application')
])

Installation

$ pip install pyinfo

Contributing

Contributions are welcome. Submit via fork and pull request.

If you're working on something major, shoot me a message beforehand

CREDITS

This library is based on the great work made by @branneman.

About

Print python information details like phpinfo

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages