From 5da17b01c4957657da7589652f590f2a71bf50e1 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Mon, 2 Mar 2020 00:43:23 +0100 Subject: [PATCH] homecontrol-dash: use double quotes --- homecontrol_dash/hcdash.py | 110 ++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/homecontrol_dash/hcdash.py b/homecontrol_dash/hcdash.py index 6dc8afb..56a1028 100755 --- a/homecontrol_dash/hcdash.py +++ b/homecontrol_dash/hcdash.py @@ -20,7 +20,7 @@ PORT=8201 def setup(): # arguments - parser = argparse.ArgumentParser(description='homecontrol') + parser = argparse.ArgumentParser(description="homecontrol") parser.add_argument("-a", "--address", dest="address", type=str, help="homecontrol address") parser.add_argument("-p", "--port", dest="port", type=str, help="dashboard port") parser.add_argument("-c", "--config", dest="config", type=str, help="config file", @@ -54,7 +54,7 @@ def setup(): config["port"] = args.port # save to file - with open(args.config, 'w') as config_file: + with open(args.config, "w") as config_file: json.dump(config, config_file) # temporary option @@ -155,7 +155,7 @@ class HCDash: app.config.suppress_callback_exceptions = True app.layout = html.Div(children=[ - html.H1(children='dashboard.ykonni.de'), + html.H1(children="dashboard.ykonni.de"), dbc.Row([ dbc.Col(dcc.Tabs(id="tabs-select-class", value=tab, children=tabs)) ]), @@ -202,9 +202,9 @@ class HCDash: @app.callback( [Output("sensor-data", "children"), - Output('slider-min', 'min'), Output('slider-min', 'value'), - Output('slider-min', 'max'), Output('slider-max', 'min'), - Output('slider-max', 'value'), Output('slider-max', 'max')], + Output("slider-min", "min"), Output("slider-min", "value"), + Output("slider-min", "max"), Output("slider-max", "min"), + Output("slider-max", "value"), Output("slider-max", "max")], [Input("tabs-select-sensor", "value")]) def update_sensor(sensorId): self.logger.debug(f"update_sensor: {sensorId}") @@ -213,37 +213,37 @@ class HCDash: dbc.Row([ dbc.Col( dcc.Graph( - id='graph-sensor-values', + id="graph-sensor-values", figure={ - 'data': [ {'x': [0], 'y': [0], 'mode': 'line', 'name': 'None'} ], - 'layout': { 'title': 'initial values' } + "data": [ {"x": [0], "y": [0], "mode": "line", "name": "None"} ], + "layout": { "title": "initial values" } } ) ) ]), dbc.Row([ dbc.Col([ - html.Div(id='slider-min-txt', style={'marginLeft': '5em', 'marginRight': '3em'}), + html.Div(id="slider-min-txt", style={"marginLeft": "5em", "marginRight": "3em"}), html.Div([ - dcc.Slider(id='slider-min', min=0, max=round(time.time()), step=600, + dcc.Slider(id="slider-min", min=0, max=round(time.time()), step=600, value=0 ), - ], style={'marginLeft': '5em', 'marginRight': '3em'} + ], style={"marginLeft": "5em", "marginRight": "3em"} ), ]), dbc.Col([ - html.Div(id='slider-max-txt', style={'marginLeft': '3em', 'marginRight': - '3em'}), + html.Div(id="slider-max-txt", style={"marginLeft": "3em", "marginRight": + "3em"}), html.Div([ - dcc.Slider(id='slider-max', min=0, max=round(time.time()), step=600, + dcc.Slider(id="slider-max", min=0, max=round(time.time()), step=600, value=round(time.time())), - ], style={'marginLeft': '3em', 'marginRight': '3em'} + ], style={"marginLeft": "3em", "marginRight": "3em"} ), ]), dbc.Col([ - html.Div(id='slider-limit-txt', style={'marginLeft': '3em', 'marginRight': '5em'}), + html.Div(id="slider-limit-txt", style={"marginLeft": "3em", "marginRight": "5em"}), html.Div([ - dcc.Slider(id='slider-limit', min=0, max=1000, step=10, value=0 ), - ], style={'marginLeft': '3em', 'marginRight': '5em'} + dcc.Slider(id="slider-limit", min=0, max=1000, step=10, value=0 ), + ], style={"marginLeft": "3em", "marginRight": "5em"} ), ]) ]), @@ -260,30 +260,30 @@ class HCDash: @app.callback( - Output('slider-min-txt', 'children'), - [Input('slider-min', 'value')]) + Output("slider-min-txt", "children"), + [Input("slider-min", "value")]) def update_slider_min_txt(value): return f"From: {self.pTime(value)}" @app.callback( - Output('slider-max-txt', 'children'), - [Input('slider-max', 'value')]) + Output("slider-max-txt", "children"), + [Input("slider-max", "value")]) def update_slider_max_txt(value): return f"To: {self.pTime(value)}" @app.callback( - Output('slider-limit-txt', 'children'), - [Input('slider-limit', 'value')]) + Output("slider-limit-txt", "children"), + [Input("slider-limit", "value")]) def update_slider_limit_txt(value): return f"Limit: {value if value > 0 else None}" @app.callback( - Output('graph-sensor-values', 'figure'), - [Input('tabs-select-sensor', 'value'), Input('slider-min', 'value'), - Input('slider-max', 'value'), Input('slider-limit', 'value')]) + Output("graph-sensor-values", "figure"), + [Input("tabs-select-sensor", "value"), Input("slider-min", "value"), + Input("slider-max", "value"), Input("slider-limit", "value")]) def update_graph_sensor_values(sensorId, min_ts, max_ts, limit): res = {} if min_ts > 0: @@ -301,8 +301,8 @@ class HCDash: x = [0] y = [0] return { - 'data': [ {'x': x, 'y': y, 'mode': 'line', 'name': f'{s}'} ], - 'layout': { 'title': f'Data for sensor: {s} ({len(x)} elements)' } + "data": [ {"x": x, "y": y, "mode": "line", "name": f"{s}"} ], + "layout": { "title": f"Data for sensor: {s} ({len(x)} elements)" } } @@ -323,37 +323,37 @@ class HCDash: dbc.Row([ dbc.Col( dcc.Graph( - id='graph-actor-values', + id="graph-actor-values", figure={ - 'data': [ {'x': [0], 'y': [0], 'mode': 'line', 'name': 'None'} ], - 'layout': { 'title': 'initial values' } + "data": [ {"x": [0], "y": [0], "mode": "line", "name": "None"} ], + "layout": { "title": "initial values" } } ) ) ]), dbc.Row([ dbc.Col([ - html.Div(id='slider-actor-min-txt', style={'marginLeft': '5em', 'marginRight': '3em'}), + html.Div(id="slider-actor-min-txt", style={"marginLeft": "5em", "marginRight": "3em"}), html.Div([ - dcc.Slider(id='slider-actor-min', min=0, max=round(time.time()), step=600, + dcc.Slider(id="slider-actor-min", min=0, max=round(time.time()), step=600, value=0 ), - ], style={'marginLeft': '5em', 'marginRight': '3em'} + ], style={"marginLeft": "5em", "marginRight": "3em"} ), ]), dbc.Col([ - html.Div(id='slider-actor-max-txt', style={'marginLeft': '3em', 'marginRight': - '3em'}), + html.Div(id="slider-actor-max-txt", style={"marginLeft": "3em", "marginRight": + "3em"}), html.Div([ - dcc.Slider(id='slider-actor-max', min=0, max=round(time.time()), step=600, + dcc.Slider(id="slider-actor-max", min=0, max=round(time.time()), step=600, value=round(time.time())), - ], style={'marginLeft': '3em', 'marginRight': '3em'} + ], style={"marginLeft": "3em", "marginRight": "3em"} ), ]), dbc.Col([ - html.Div(id='slider-actor-limit-txt', style={'marginLeft': '3em', 'marginRight': '5em'}), + html.Div(id="slider-actor-limit-txt", style={"marginLeft": "3em", "marginRight": "5em"}), html.Div([ - dcc.Slider(id='slider-actor-limit', min=0, max=1000, step=10, value=0 ), - ], style={'marginLeft': '3em', 'marginRight': '5em'} + dcc.Slider(id="slider-actor-limit", min=0, max=1000, step=10, value=0 ), + ], style={"marginLeft": "3em", "marginRight": "5em"} ), ]) ]), @@ -379,24 +379,24 @@ class HCDash: @app.callback( - Output('slider-actor-min-txt', 'children'), - [Input('slider-actor-min', 'value')]) + Output("slider-actor-min-txt", "children"), + [Input("slider-actor-min", "value")]) def update_slider_actor_min_txt(value): # self.logger.debug(f"update_slider_actor_min_txt: {value}") return f"From: {self.pTime(value)}" @app.callback( - Output('slider-actor-max-txt', 'children'), - [Input('slider-actor-max', 'value')]) + Output("slider-actor-max-txt", "children"), + [Input("slider-actor-max", "value")]) def update_slider_actor_max_txt(value): # self.logger.debug(f"update_slider_actor_max_txt: {value}") return f"To: {self.pTime(value)}" @app.callback( - Output('slider-actor-limit-txt', 'children'), - [Input('slider-actor-limit', 'value')]) + Output("slider-actor-limit-txt", "children"), + [Input("slider-actor-limit", "value")]) def update_slider_actor_limit_txt(value): return f"Limit: {value if value > 0 else None}" @@ -411,9 +411,9 @@ class HCDash: return "" @app.callback( - Output('graph-actor-values', 'figure'), - [Input('tabs-select-actor', 'value'), Input('slider-actor-min', 'value'), - Input('slider-actor-max', 'value'), Input('slider-actor-limit', 'value')]) + Output("graph-actor-values", "figure"), + [Input("tabs-select-actor", "value"), Input("slider-actor-min", "value"), + Input("slider-actor-max", "value"), Input("slider-actor-limit", "value")]) def update_graph_actor(actorId, min_ts, max_ts, limit): self.logger.debug(f"update_graph_actor: {actorId}, {min_ts}, {max_ts}, {limit}") res = {} @@ -431,8 +431,8 @@ class HCDash: x = [0] y = [0] return { - 'data': [ {'x': x, 'y': y, 'mode': 'markers', 'name': f'{s}'} ], - 'layout': { 'title': f'Data for sensor: {s} ({len(x)} elements)' } + "data": [ {"x": x, "y": y, "mode": "markers", "name": f"{s}"} ], + "layout": { "title": f"Data for sensor: {s} ({len(x)} elements)" } } @@ -445,5 +445,5 @@ def main(): hcd = HCDash(config) hcd.main() -if __name__ == '__main__': +if __name__ == "__main__": main()