f-klubben / jvm

A smtp server for handling the emails from Wittenborg 9100
0 stars 0 forks source link

JVM

Statistics collector and generator for Wittenborg-91XX coffee-machine.

Jinja2 required for running. Black for formatting the code.

Get started:

python3 server.py

Run tests

python3 test.py

Styling

The project uses Black for formatting the code.

black --target-version py36 --line-length 120 --skip-string-normalization *.py

Systemd service

See coffee.service for in-use service. Service runs server.py to periodically handle mails and generate statistics. Generated html is symlinked to /var/www/coffee, which Apache exposes with SSL-cert stapling.

Technical details

Intercepting mails

The project acts as a SMTP server for the coffemachine using the smtplib. The coffeemachine sends a lot of mails to the server. This project then handles each of these mails.

For capturing SMTP mails for later test use:

python3 server.py capture

Emails are then saved under logged_mails/

Updating estimates

The coffeemachine has an internal counter for keeping track of the ingredients in the machine. The levels are being sent out using mails, but it only sends for 3 thresholds: Full, Empty and User Threshold. This complicates the collection of metrics to use in statistics. As such, the project creates estimates based on 2 other mails:

Generation of statistics

Inside generator there is a script which queries the database and creates a HTML report page.