Skip to content

A Flask demo app connecting the UPower battery status with DBUS to a website with socket.io

License

Notifications You must be signed in to change notification settings

infothrill/flask-socketio-dbus-demo

Repository files navigation

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

  • DBUS
  • python2.7+ or python3.5+ (not sure about the versions in between, I never tried)

Challenges encountered

  • python-dbus didn't work for this, because it can't be run in a subthread while still using its main loop

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

About

A Flask demo app connecting the UPower battery status with DBUS to a website with socket.io

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published