Giter Club home page Giter Club logo

pyinfo's Introduction

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.

pyinfo's People

Contributors

mastropinguino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tlex cbueche

pyinfo's Issues

Using pyinfo.info_as_html() get error on python 3.8.1 working fine on 3.6.8

10.88.0.1 - - [20/Jan/2020 00:14:07] "GET /python-hello-world/health HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/flask/app.py", line 2463, in call
return self.wsgi_app(environ, start_response)
File "/usr/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/app/app.py", line 14, in info
return pyinfo.info_as_html()
File "/usr/lib/python3.8/site-packages/pyinfo/_pyinfo.py", line 240, in info_as_html
info = python_info()
File "/usr/lib/python3.8/site-packages/pyinfo/_pyinfo.py", line 49, in python_info
data['System information'] = collect_system_info()
File "/usr/lib/python3.8/site-packages/pyinfo/_pyinfo.py", line 73, in collect_system_info
if platform.dist()[0] != '' and platform.dist()[1] != '':
AttributeError: module 'platform' has no attribute 'dist'
1

platform Linux latest stable alpine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.