mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-22 09:26:16 +00:00
fix circular import
This commit is contained in:
+8
-2
@@ -1,5 +1,4 @@
|
||||
import json
|
||||
import sqlite3
|
||||
import traceback
|
||||
from datetime import datetime, timezone
|
||||
import dash_bootstrap_components as dbc
|
||||
@@ -9,10 +8,12 @@ import dash_html_components as html
|
||||
from MyLogger import logger
|
||||
from flask import jsonify, request, Response as FlaskResponse
|
||||
|
||||
from MyPSACC import MyPSACC
|
||||
from psa_connectedcar.models import trips
|
||||
from web import figures
|
||||
|
||||
from MyPSACC import MyPSACC
|
||||
from web.app import app, dash_app, myp, chc, save_config
|
||||
from web.db import conn
|
||||
|
||||
|
||||
@dash_app.callback(Output('trips_map', 'figure'),
|
||||
@@ -103,6 +104,7 @@ def after_request(response):
|
||||
header['Access-Control-Allow-Origin'] = '*'
|
||||
return response
|
||||
|
||||
|
||||
def update_trips():
|
||||
global trips
|
||||
logger.info("update_trips")
|
||||
@@ -111,6 +113,7 @@ def update_trips():
|
||||
except:
|
||||
logger.error("update_trips: "+traceback.format_exc())
|
||||
|
||||
|
||||
try:
|
||||
update_trips()
|
||||
min_date = trips[0].start_at
|
||||
@@ -155,3 +158,6 @@ dash_app.layout = dbc.Container(fluid=True, children=[
|
||||
data_div
|
||||
])
|
||||
|
||||
conn.create_function("update_trips", 0, update_trips)
|
||||
conn.execute("CREATE TRIGGER IF NOT EXISTS update_trigger AFTER INSERT ON position BEGIN SELECT update_trips(); END;")
|
||||
conn.commit()
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from web.callback import update_trips
|
||||
|
||||
|
||||
def convert_datetime(st):
|
||||
return datetime.strptime(st.decode("utf-8"), "%Y-%m-%d %H:%M:%S+00:00").replace(tzinfo=pytz.UTC)
|
||||
@@ -15,6 +12,6 @@ conn = sqlite3.connect('info.db', detect_types=sqlite3.PARSE_DECLTYPES | sqlite3
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.execute("CREATE TABLE IF NOT EXISTS position (Timestamp DATETIME PRIMARY KEY, VIN TEXT, longitude REAL, "
|
||||
"latitude REAL, mileage REAL, level INTEGER);")
|
||||
conn.create_function("update_trips",0,update_trips)
|
||||
conn.execute("CREATE TRIGGER IF NOT EXISTS update_trigger AFTER INSERT ON position BEGIN SELECT update_trips(); END;")
|
||||
conn.commit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user