From 099a681dacf788ab7c128bebd79af092955a581e Mon Sep 17 00:00:00 2001 From: Stefan Hackenberg Date: Wed, 24 Jul 2024 14:43:55 +0200 Subject: [PATCH] Print semver instead of githash on welcome --- coffeebuddy/__init__.py | 14 ++++++++------ coffeebuddy/route_welcome.py | 6 ++---- coffeebuddy/templates/welcome.html | 2 +- pyproject.toml | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/coffeebuddy/__init__.py b/coffeebuddy/__init__.py index 0cbcf4f..abd8ebb 100644 --- a/coffeebuddy/__init__.py +++ b/coffeebuddy/__init__.py @@ -13,6 +13,8 @@ from flask_sqlalchemy import SQLAlchemy from sqlalchemy.exc import OperationalError +__version__ = "1.1.0" + db = SQLAlchemy() login_manager = flask_login.LoginManager() @@ -46,7 +48,7 @@ def create_app(config=None): if config: app.config.update(config) - if app.config.get("ENV") in ("development", "prefilled") or app.testing: + if app.config.get("PREFILLED") or app.testing: app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:" @app.teardown_appcontext @@ -68,7 +70,7 @@ def init_db(app): flask.current_app.config["DB_BACKEND"] == "sqlite" and not os.path.exists("coffee.db") ) - or flask.current_app.config.get("ENV") in ("development", "prefilled") + or flask.current_app.config.get("PREFILLED") or flask.current_app.testing ): try: @@ -78,7 +80,10 @@ def init_db(app): os._exit(1) # Default database content - if flask.current_app.config.get("ENV") == "development": + if not flask.current_app.testing and flask.current_app.config.get("PREFILLED"): + flask.current_app.debug = True + prefill() + elif flask.current_app.debug: flask.current_app.db.session.add( coffeebuddy.model.User( tag=bytes.fromhex("01020304"), @@ -88,9 +93,6 @@ def init_db(app): ) ) flask.current_app.db.session.commit() - elif flask.current_app.config.get("ENV") == "prefilled": - flask.current_app.debug = True - prefill() if flask.current_app.config["GUEST"]: if not coffeebuddy.model.User.query.filter( diff --git a/coffeebuddy/route_welcome.py b/coffeebuddy/route_welcome.py index 9b4f576..af9f61e 100644 --- a/coffeebuddy/route_welcome.py +++ b/coffeebuddy/route_welcome.py @@ -1,9 +1,9 @@ import datetime import socket -import subprocess import flask +import coffeebuddy from coffeebuddy.model import Drink @@ -18,7 +18,5 @@ def welcome(): "welcome.html", dataset=data, hostname=socket.gethostname(), - githash=subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) - .decode("ascii") - .strip(), + version=coffeebuddy.__version__, ) diff --git a/coffeebuddy/templates/welcome.html b/coffeebuddy/templates/welcome.html index e2ffdbd..4679898 100644 --- a/coffeebuddy/templates/welcome.html +++ b/coffeebuddy/templates/welcome.html @@ -93,7 +93,7 @@

Tap your card to continue

Hostname
{{ hostname }}
Version
-
{{ githash }}
+
{{ version }}
{% if config['GUEST'] %} diff --git a/pyproject.toml b/pyproject.toml index d90b72a..9480ab5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "coffeebuddy" -version = "1.0.0" +dynamic = ["version"] description = "WebApp for Raspi to track your teams' coffee consumption digitally." authors = [{ name = "Stefan Hackenberg", email = "mail@stefan-hackenberg.de" }] dependencies = [