From e011ea9d5e1af17ba050f5ce924c4dfcb12fe8c3 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Fri, 12 Jun 2026 14:33:07 +0200 Subject: [PATCH] fix: not vehicles --- Dockerfile | 2 +- psa_car_controller/web/view/api.py | 2 ++ psa_car_controller/web/view/views.py | 8 +++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 56bc87c..4ad06a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG PYTHON_DEP='python3 python3-wheel python3-typing-extensions python3-pandas python3-six python3-dateutil python3-brotli python3-pycryptodome libatlas3-base python3-cryptography python3-scipy androguard python3-flask python3-paho-mqtt python3-ruamel.yaml ca-certificates python3-numpy' ARG DEBIAN_FRONTEND=noninteractive FROM debian:bookworm-slim AS builder -ARG PSACC_VERSION="0.0.0" ARG PYTHON_DEP RUN BUILD_DEP='python3-pip python3-setuptools python3-dev libblas-dev liblapack-dev gfortran libffi-dev libxml2-dev libxslt1-dev make automake gcc g++ subversion ninja-build' ; \ apt-get update && apt-get install -y --no-install-recommends $BUILD_DEP $PYTHON_DEP; +ARG PSACC_VERSION="0.0.0" RUN pip3 install --break-system-packages --upgrade pip wheel setuptools COPY ./dist/psa_car_controller-${PSACC_VERSION}-py3-none-any.whl . RUN pip3 install --break-system-packages --no-cache-dir psa_car_controller-${PSACC_VERSION}-py3-none-any.whl diff --git a/psa_car_controller/web/view/api.py b/psa_car_controller/web/view/api.py index 3762592..739901c 100644 --- a/psa_car_controller/web/view/api.py +++ b/psa_car_controller/web/view/api.py @@ -190,6 +190,8 @@ def settings_section(section: str): @app.route('/vehicles/trips') def get_trips(): try: + if not APP.myp.vehicles_list: + return jsonify({}) car = APP.myp.vehicles_list[0] trips_by_vin = Trips.get_trips(Cars([car])) trips = trips_by_vin[car.vin] diff --git a/psa_car_controller/web/view/views.py b/psa_car_controller/web/view/views.py index 271c77f..fb15699 100644 --- a/psa_car_controller/web/view/views.py +++ b/psa_car_controller/web/view/views.py @@ -110,7 +110,8 @@ def create_callback(): # noqa: MC0001 conn = Database.get_db() charge = Charge(datetime.utcfromtimestamp(changed_line['start_at'] / 1000)) charge.price = changed_line['current_value'] - charge.vin = get_default_car().vin + if APP.myp.vehicles_list: + charge.vin = get_default_car().vin if not Database.set_chargings_price(conn, charge): logger.error("Can't find line to update in the database") else: @@ -128,7 +129,8 @@ def create_callback(): # noqa: MC0001 is_open = False if active_cell is not None and active_cell["column_id"] in ["start_level", "end_level"] and not is_open: row = data[active_cell["row"]] - return figures.get_battery_curve_fig(row, APP.myp.vehicles_list[0]), True + if APP.myp.vehicles_list: + return figures.get_battery_curve_fig(row, APP.myp.vehicles_list[0]), True return "", False @dash_app.callback([Output("tab_trips_popup_graph", "children"), Output("tab_trips_popup", "is_open"), ], @@ -193,7 +195,7 @@ def update_trips(): Database.add_altitude_to_db(conn) min_date = None max_date = None - if APP.is_good: + if APP.is_good and APP.myp.vehicles_list: car = get_default_car() # todo handle multiple car try: trips_by_vin = Trips.get_trips(Cars([car]))