style: apply autopep8

This commit is contained in:
Florian Bezannier
2024-01-08 08:57:16 +01:00
committed by Florian BEZANNIER
parent 5a2f09e2d6
commit ea01bcb6b7
7 changed files with 81 additions and 80 deletions
@@ -76,7 +76,7 @@ class PSACarController(metaclass=Singleton):
def load_app(self) -> bool:
# pylint: disable=too-many-branches
my_logger(handler_level=int(self.args.debug))
logger.info("App version %s", __version__)
if self.args.config:
self.config_name = self.args.config
@@ -108,4 +108,4 @@ class Charging:
/ 60,
"duration_str": str((c.get("stop_at") - c.get("start_at"))),
}
)
)
+2 -2
View File
@@ -325,9 +325,9 @@ class Database:
def get_all_charge() -> List[Charge]:
conn = Database.get_db()
res = conn.execute("select * from battery ORDER BY start_at").fetchall()
conn.close()
conn.close()
return res
@staticmethod
def update_charge(charge: Charge):
# we don't need to update mileage, since it should be inserted at beginning of charge,
+2 -2
View File
@@ -76,8 +76,8 @@ def config_flask(title, base_path, debug: bool, host, port, reloader=False, # p
else:
application = DispatcherMiddleware(Flask('dummy_app'), {base_path: app})
requests_pathname_prefix = base_path + "/"
dash_app = DashCustom(external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.BOOTSTRAP],
external_scripts=locale_url, title=title,
dash_app = DashCustom(external_stylesheets=[dbc.themes.BOOTSTRAP, dbc.icons.BOOTSTRAP],
external_scripts=locale_url, title=title,
server=app, requests_pathname_prefix=requests_pathname_prefix,
suppress_callback_exceptions=True, serve_locally=False)
dash_app.enable_dev_tools(debug)
+1
View File
@@ -29,6 +29,7 @@ def get_vehicle_info(vin):
)
return response
@app.route("/style.json")
def get_style():
global STYLE_CACHE
+73 -73
View File
@@ -48,20 +48,20 @@ def get_default_car() -> Car:
def add_header(el):
version = "v" + __version__
github_url= "https://github.com/flobz/psa_car_controller/releases/tag/"+version
github_url = "https://github.com/flobz/psa_car_controller/releases/tag/" + version
dbc_version = dbc.Button(html.I(version, className="m-1"),
size='sm',
color="secondary",
color="secondary",
className="me-1 bi bi-github",
external_link =True, href=github_url)
external_link=True, href=github_url)
return dbc.Row([dbc.Col(dcc.Link(html.H1('My car info'), href=dash_app.requests_pathname_external_prefix,
style={"TextDecoration": "none"})),
dbc.Col(html.Div([dbc_version,
dcc.Link(html.Img(src="assets/images/settings.svg", width="30veh"),
href=dash_app.requests_pathname_external_prefix + "config",
className="float-end")],
dcc.Link(html.Img(src="assets/images/settings.svg", width="30veh"),
href=dash_app.requests_pathname_external_prefix + "config",
className="float-end")],
className="d-grid gap-2 d-md-flex justify-content-md-end",))],
className='align-items-center'), el
className='align-items-center'), el
@dash_app.callback(Output('page-content', 'children'),
@@ -104,7 +104,7 @@ def create_callback(): # noqa: MC0001
for changed_line in diff_data:
if changed_line['column_name'] == 'price':
conn = Database.get_db()
charge = Charge(datetime.utcfromtimestamp(changed_line['start_at']/1000))
charge = Charge(datetime.utcfromtimestamp(changed_line['start_at'] / 1000))
charge.price = changed_line['current_value']
charge.vin = get_default_car().vin
if not Database.set_chargings_price(conn, charge):
@@ -139,11 +139,11 @@ def create_callback(): # noqa: MC0001
return "", False
@dash_app.callback(Output("loading-output-trips", "children"), Input("export-trips-table", "n_clicks"))
def export_trips_loading_animation(n_clicks): # pylint: disable=unused-argument
def export_trips_loading_animation(n_clicks): # pylint: disable=unused-argument
time.sleep(3)
@dash_app.callback(Output("loading-output-battery", "children"), Input("export-battery-table", "n_clicks"))
def export_batt_loading_animation(n_clicks): # pylint: disable=unused-argument
def export_batt_loading_animation(n_clicks): # pylint: disable=unused-argument
time.sleep(3)
# Emulate click on original Export datatables button, since original button is hard to modify
dash_app.clientside_callback(
@@ -268,75 +268,75 @@ def serve_layout():
dbc.Tab(label="Summary", tab_id="summary", children=summary_tab),
dbc.Tab(label="Trips", tab_id="trips", id="tab_trips",
children=[dbc.Row(
dbc.Col([
dcc.Loading(
id="loading-div-trips",
children=[html.Div([html.Div(id="loading-output-trips")])],
type="circle",
className="export-load-anim"
),
dbc.Button("Export trips data",
id="export-trips-table",
n_clicks=0,
size="sm",
color="light",
className="m-1 w-200"
)],
className="d-grid gap-2 d-md-flex justify-content-md-end"
)
),
html.Div(id="tab_trips_fig", children=figures.table_fig),
dbc.Modal(
[
dbc.ModalHeader("Altitude"),
dbc.ModalBody(html.Div(
dbc.Col([
dcc.Loading(
id="loading-div-trips",
children=[html.Div([html.Div(id="loading-output-trips")])],
type="circle",
className="export-load-anim"
),
dbc.Button("Export trips data",
id="export-trips-table",
n_clicks=0,
size="sm",
color="light",
className="m-1 w-200"
)],
className="d-grid gap-2 d-md-flex justify-content-md-end"
)
),
html.Div(id="tab_trips_fig", children=figures.table_fig),
dbc.Modal(
[
dbc.ModalHeader("Altitude"),
dbc.ModalBody(html.Div(
id="tab_trips_popup_graph")),
dbc.ModalFooter(
dbc.Button("Close",
id="tab_trips_popup-close",
className="ml-auto")
),
],
id="tab_trips_popup",
size="xl",
dbc.ModalFooter(
dbc.Button("Close",
id="tab_trips_popup-close",
className="ml-auto")
),
],
id="tab_trips_popup",
size="xl",
)
]),
dbc.Tab(label="Charge", tab_id="charge", id="tab_charge",
children=[dbc.Row(
dbc.Col([
dcc.Loading(
id="loading-div-battery",
children=[html.Div([html.Div(id="loading-output-battery")])],
type="circle",
className="export-load-anim"
),
dbc.Button("Export charging data",
id="export-battery-table",
n_clicks=0,
size="sm",
color="light",
className="m-1 w-200"
)],
className="d-grid gap-2 d-md-flex justify-content-md-end"
)
),
figures.battery_table,
dbc.Modal(
[
dbc.ModalHeader(
"Charging speed"),
dbc.ModalBody(html.Div(
dbc.Col([
dcc.Loading(
id="loading-div-battery",
children=[html.Div([html.Div(id="loading-output-battery")])],
type="circle",
className="export-load-anim"
),
dbc.Button("Export charging data",
id="export-battery-table",
n_clicks=0,
size="sm",
color="light",
className="m-1 w-200"
)],
className="d-grid gap-2 d-md-flex justify-content-md-end"
)
),
figures.battery_table,
dbc.Modal(
[
dbc.ModalHeader(
"Charging speed"),
dbc.ModalBody(html.Div(
id="tab_battery_popup_graph")),
dbc.ModalFooter(
dbc.Button("Close",
id="tab_battery_popup-close",
className="ml-auto")
),
],
id="tab_battery_popup",
size="xl",
)
]),
dbc.ModalFooter(
dbc.Button("Close",
id="tab_battery_popup-close",
className="ml-auto")
),
],
id="tab_battery_popup",
size="xl",
)
]),
dbc.Tab(label="Map", tab_id="map", children=[maps]),
dbc.Tab(label="Control", tab_id="control", children=html.Iframe(
src=request.url_root + "control?header=false",
+1 -1
View File
@@ -238,7 +238,7 @@ class TestUnit(unittest.TestCase):
assert compare_dict(chargings, [{'start_at': date0,
'stop_at': date3,
'duration_str': duration_str,
'duration_min' :duration_min,
'duration_min': duration_min,
'VIN': 'VR3UHZKX',
'start_level': 40,
'end_level': 85,