From ec91466fe4201b75dae2fd74a6c5798e055d3c07 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sat, 16 Apr 2022 08:42:44 -0500 Subject: [PATCH] lint fixes --- frigate/app.py | 4 ++-- frigate/config.py | 6 +++++- frigate/events.py | 20 ++++++++++---------- frigate/mqtt.py | 15 ++++++++++----- frigate/stats.py | 4 +++- frigate/video.py | 4 +++- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index efea7d92c..be581364f 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -93,8 +93,8 @@ class FrigateApp: "i", self.config.cameras[camera_name].detect.enabled ), "improve_contrast_enabled": mp.Value( - "i", self.config.cameras[camera_name].motion.improve_contrast - ), + "i", self.config.cameras[camera_name].motion.improve_contrast + ), "detection_fps": mp.Value("d", 0.0), "detection_frame": mp.Value("d", 0.0), "read_start": mp.Value("d", 0.0), diff --git a/frigate/config.py b/frigate/config.py index fd89907e4..49195f51b 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -43,9 +43,11 @@ class DetectorConfig(FrigateBaseModel): device: str = Field(default="usb", title="Device Type") num_threads: int = Field(default=3, title="Number of detection threads") + class UIConfig(FrigateBaseModel): use_experimental: bool = Field(default=False, title="Experimental UI") + class MqttConfig(FrigateBaseModel): host: str = Field(title="MQTT Host") port: int = Field(default=1883, title="MQTT Port") @@ -516,7 +518,9 @@ class CameraLiveConfig(FrigateBaseModel): class CameraUiConfig(FrigateBaseModel): order: int = Field(default=0, title="Order of camera in UI.") - dashboard: bool = Field(default=True, title="Show this camera in Frigate dashboard UI.") + dashboard: bool = Field( + default=True, title="Show this camera in Frigate dashboard UI." + ) class CameraConfig(FrigateBaseModel): diff --git a/frigate/events.py b/frigate/events.py index 747a35cac..2dfe40f3e 100644 --- a/frigate/events.py +++ b/frigate/events.py @@ -14,22 +14,22 @@ from frigate.models import Event logger = logging.getLogger(__name__) + def should_insert_db(prev_event, current_event): """If current event has new clip or snapshot.""" - return ( - (not prev_event["has_clip"] and not prev_event["has_snapshot"]) - and (current_event["has_clip"] or current_event["has_snapshot"]) + return (not prev_event["has_clip"] and not prev_event["has_snapshot"]) and ( + current_event["has_clip"] or current_event["has_snapshot"] ) + def should_update_db(prev_event, current_event): """If current_event has updated fields and (clip or snapshot).""" - return ( - (current_event["has_clip"] or current_event["has_snapshot"]) - and (prev_event["top_score"] != current_event["top_score"] - or prev_event["entered_zones"] != current_event["entered_zones"] - or prev_event["thumbnail"] != current_event["thumbnail"] - or prev_event["has_clip"] != current_event["has_clip"] - or prev_event["has_snapshot"] != current_event["has_snapshot"]) + return (current_event["has_clip"] or current_event["has_snapshot"]) and ( + prev_event["top_score"] != current_event["top_score"] + or prev_event["entered_zones"] != current_event["entered_zones"] + or prev_event["thumbnail"] != current_event["thumbnail"] + or prev_event["has_clip"] != current_event["has_clip"] + or prev_event["has_snapshot"] != current_event["has_snapshot"] ) diff --git a/frigate/mqtt.py b/frigate/mqtt.py index f73536801..e96bb674e 100644 --- a/frigate/mqtt.py +++ b/frigate/mqtt.py @@ -111,7 +111,7 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics): logger.warning(f"Received unsupported value at {message.topic}: {payload}") state_topic = f"{message.topic[:-4]}/state" - client.publish(state_topic, payload, retain=True) + client.publish(state_topic, payload, retain=True) def on_restart_command(client, userdata, message): restart_frigate() @@ -120,9 +120,13 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics): threading.current_thread().name = "mqtt" if rc != 0: if rc == 3: - logger.error("Unable to connect to MQTT server: MQTT Server unavailable") + logger.error( + "Unable to connect to MQTT server: MQTT Server unavailable" + ) elif rc == 4: - logger.error("Unable to connect to MQTT server: MQTT Bad username or password") + logger.error( + "Unable to connect to MQTT server: MQTT Bad username or password" + ) elif rc == 5: logger.error("Unable to connect to MQTT server: MQTT Not authorized") else: @@ -153,7 +157,8 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics): f"{mqtt_config.topic_prefix}/{name}/detect/set", on_detect_command ) client.message_callback_add( - f"{mqtt_config.topic_prefix}/{name}/improve_contrast/set", on_improve_contrast_command + f"{mqtt_config.topic_prefix}/{name}/improve_contrast/set", + on_improve_contrast_command, ) client.message_callback_add( @@ -204,7 +209,7 @@ def create_mqtt_client(config: FrigateConfig, camera_metrics): f"{mqtt_config.topic_prefix}/{name}/improve_contrast/state", "ON" if config.cameras[name].motion.improve_contrast else "OFF", retain=True, - ) + ) return client diff --git a/frigate/stats.py b/frigate/stats.py index ba7c34cc2..ed4797d32 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -15,7 +15,9 @@ logger = logging.getLogger(__name__) def get_latest_version() -> str: - request = requests.get('https://api.github.com/repos/blakeblackshear/frigate/releases/latest') + request = requests.get( + "https://api.github.com/repos/blakeblackshear/frigate/releases/latest" + ) response = request.json() if request.ok and response: diff --git a/frigate/video.py b/frigate/video.py index 2ea1ae1a0..c51f7cf2d 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -368,7 +368,9 @@ def track_camera( objects_to_track = config.objects.track object_filters = config.objects.filters - motion_detector = MotionDetector(frame_shape, config.motion, improve_contrast_enabled) + motion_detector = MotionDetector( + frame_shape, config.motion, improve_contrast_enabled + ) object_detector = RemoteObjectDetector( name, labelmap, detection_queue, result_connection, model_shape )