Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mastropinguino/pyinfo
Print python information details like phpinfo
https://github.com/mastropinguino/pyinfo
pip python systeminfo wsgi
Last synced: 2 days ago
JSON representation
Print python information details like phpinfo
- Host: GitHub
- URL: https://github.com/mastropinguino/pyinfo
- Owner: mastropinguino
- License: mit
- Created: 2017-11-11T07:58:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-27T15:16:43.000Z (over 4 years ago)
- Last Synced: 2024-08-09T10:29:46.338Z (3 months ago)
- Topics: pip, python, systeminfo, wsgi
- Language: Python
- Size: 9.77 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```bash$ 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
```python
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
```python
def application(environ, start_response):
import pyinfooutput = pyinfo.info_as_html()
start_response('200 OK', [('Content-type', 'text/html')])
return [output]
```or using a wsgi capable webserver like gunicorn:
```bash
$ gunicorn pyinfo.wsgi
```## Mount into WSGI application
Eg. using flask
```python
# flask_example.pyfrom flask import Flask
app = Flask(__name__)
@app.route('/pyinfo')
def info():
import pyinfo
return pyinfo.info_as_html()
```Even with webapp2
```python
# webapp2_example.pyfrom webapp2 import Route, WSGIApplication
APP = WSGIApplication([
Route('/pyinfo', handler='pyinfo.wsgi.application')
])
```# Installation
```bash
$ 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](https://gist.github.com/branneman/951825).