infothrill / flask-socketio-dbus-demo

A Flask demo app connecting the UPower battery status with DBUS to a website with socket.io
MIT License
8 stars 4 forks source link
dbus demo flask python socket-io upower

What is this?

An demo Flask application that sends websocket messages to the browser originating from the Linux DBUS, in this case from the UPower daemon. There is only one relevant page in this demo so far, which shows the battery status of the host it is run on.

This only works on Linux, was originally developed on Ubuntu 13.10, but also works on Ubuntu 14.04.

Installation on Ubuntu

See provision.sh for basic python and system dependencies.

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt

A sample Vagrantfile is provided to get started on Ubuntu 14.04 and 16.04.

Running it

Start the webservice:

python run.py 0.0.0.0

Requirements

Challenges encountered

Useful links and further reading

https://pypi.python.org/pypi/python-tdbus

http://upower.freedesktop.org/

Linux Journal article on DBUS: http://www.linuxjournal.com/article/10455?page=0,0