| config | ||
| libs | ||
| logs | ||
| raspberry_config_examples | ||
| src/saunatable | ||
| .gitignore | ||
| .gitmodules | ||
| .pre-commit-config.yaml | ||
| docker-compose.yml | ||
| Dockerfile | ||
| pdm.lock | ||
| pyproject.toml | ||
| README.md | ||
HaDiKo Saunatable
A small tool to scrape a pretix installation for upcoming events.
IMPORTANT NOTE: This repo uses submodules, so make sure to keep them to the current master branch
Link to a brief submodule tutorial here.
Local (Virtual Environment) Installation
If necessary get python:
# install python3 and python3-pip
apt install python3 python3-pip virtualenv
Get script running:
# copy this repo
## use --recursive to get the submodules
git clone --recursive https://git.univ-exp.com/HDK/Saunatable.git
cd Saunatable
# install pdm
pip3 install -U pdm
# copy sample config
cp ./config/config.toml.example ./config/config.toml
# edit config
nano ./config/config.cfg
# run program
pdm run SaunaTable
Setup
Change the default values in the file ./config/config.toml, all values in the sections
[AppSettings]api_key→ change your pretix API keypretix_server→ your pretix server URLpreview_days→ the upcoming days for which the table should be generatedorganizers→ the pretix organizer names to search for eventsshow_orders(optional, defaults totrue) → add a link to the orders in the tableprivacymode(optional, defaults tofalse) → use of privacy mode. Also triggerable by argument.diplaytime_pre_timeslot(optional, defaults to15) → show attendee names this # minutes in advance from nowdiplaytime_post_timeslot(optional, defaults to15) → show attendee names this # minutes longer from nowlog_level(optional, default isINFO) → log level for the loggerlog_file(optional, defaults tonone) → the log file to write tolocale(optional) → the locale in country code (e.g.de) to use, defaults to your system localetimezone(optional) → the timezone to use, defaults to your system timezone
[WebInterface]enabled→ enable the web interfaceport→ the port to listen onhost→ the host to listen onlocation(optional, defaults to/) → the location to listen on, ( e.g.your-server.com:port/SaunaTable/),
URL Parameters
The following URL query-parameters are available:
days(int) → the number of days to show in the future, overrides the config valuepreview_days, the command line argument--preview-daysand the web-interface inputprivacy(true|false) → set privacy mode, overrides the config valueprivacymodeand the command line argument--privacyshow_orders(true|false) → show the orders in the table, overrides the config valueshow_ordersno_menu(true|false) → hide the menu, useful for embedding the tableauto_update(true) → auto update the table everyauto_update_intervalseconds.auto_update_interval(int>=5) → the interval in seconds to auto update the table. Defaults to 60 seconds.
Example:
http://your-server.com:8080/?days=3&privacy=true&show_orders=false&no_menu=true&auto_update=true&auto_update_interval=10
Systemd Unit
Use the following example to run the script as a systemd service.
[Unit]
Description=SaunaTable
After=network.target
[Service]
# set your username here
User=username
# set your group here
Group=groupname
# set your working directory to your installation
WorkingDirectory=/opt/SaunaTable
# set your virtual environment (PDM creates .venv)
ExecStart=/opt/SaunaCancelWatchdog/.venv/bin/SaunaTable
Restart=always
[Install]
WantedBy=multi-user.target
Docker Installation
Make sure to have completed the setup before running the docker container. The
folders ./config and ./logs are mounted to the container.
# builds the docker image and starts the container
docker compose up -d
Optional parameters
Use pdm run SaunaTable --help to get the following help:
Usage: SaunaTable [OPTIONS]
╭─ Options ───────────────────────────────────────────────────────────────────────╮
│ --config PATH path to the config.toml file │
│ --since TEXT Create the tables since a given DATE in any format │
│ recognized by pendulum │
│ --preview-days INTEGER Create the tables for the next N days │
│ --web-interface Enable web interface and start a web server to show │
│ the tables │
│ --privacy Enable privacy and only show current window from │
│ config.toml │
│ --highscore Print highscore instead of shifts table │
│ --help Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────╯
Apache2 Redirect
To generate the AuthUserFile just use
the htpasswd
command.
The following example uses
the location /SaunaTable.
Make sure to set the same location in your config file as in the apache
config file.
```# /etc/apache2/sites-available/saunatable.conf
# [...] virtual host configuration
# Reverse proxy configuration for Plotly Dash app
ProxyPreserveHost On
ProxyPass /SaunaTable http://localhost:8088/SaunaTable
ProxyPassReverse /SaunaTable http://localhost:8088/SaunaTable
# Optional: Add these lines if you want to handle WebSocket connections
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule /SaunaTable/(.*) ws://localhost:8088/SaunaTable/$1 [P,L]
# Basic Authentication configuration for /SaunaTable
<Location /SaunaTable>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/htpasswd-files/saunatable.htpasswd
Require valid-user
</Location>
# [...] virtual host configuration
Then just visit https://your-example-server.com:port and login with the user
and password.
Update Submodules
# from inside repo run the following to pull submodules
git submodule update --init --recursive
# to pull submodules to the latest commit
git submodule update --remote --merge
# after submodule update you might want to commit the change
git commit -am "updated submodules"
git push
Linting
Use ruff and pre-commit to lint the code.
# install pre-commit, and ruff
pip3 install -U pre-commit ruff
# install pre-commit hooks
pre-commit install
License
Author Stefan Maier Licence GNU GPLv3
Contributing
Bug reports and pull requests are welcome on my website or mail to git@univ-exp.com