NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Safely load config file for go2rtc (#11491)
Nicolas Mowen4d05bc25f4da
diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.pyindex f3e4bdaa59..44d2170eed 100644--- a/docker/main/rootfs/usr/local/go2rtc/create_config.py+++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py@@ -32,13 +32,16 @@ config_file_yaml = config_file.replace(".yml", ".yaml")if os.path.isfile(config_file_yaml):config_file = config_file_yaml-with open(config_file) as f:- raw_config = f.read()--if config_file.endswith((".yaml", ".yml")):- config: dict[str, any] = yaml.safe_load(raw_config)-elif config_file.endswith(".json"):- config: dict[str, any] = json.loads(raw_config)+try:+ with open(config_file) as f:+ raw_config = f.read()++ if config_file.endswith((".yaml", ".yml")):+ config: dict[str, any] = yaml.safe_load(raw_config)+ elif config_file.endswith(".json"):+ config: dict[str, any] = json.loads(raw_config)+except FileNotFoundError:+ config: dict[str, any] = {}go2rtc_config: dict[str, any] = config.get("go2rtc", {})diff --git a/frigate/util/builtin.py b/frigate/util/builtin.pyindex 1536d9799a..134d3d4673 100644--- a/frigate/util/builtin.py+++ b/frigate/util/builtin.py@@ -279,7 +279,7 @@ def find_by_key(dictionary, target_key):return None-def save_default_config(location: str):+def save_default_config(location: str) -> None:try:with open(location, "w") as f:f.write(@@ -303,6 +303,11 @@ cameras:)except PermissionError:logger.error("Unable to write default config to /config")+ return++ logger.info(+ "Created default config file, see the getting started docs for configuration https://docs.frigate.video/guides/getting_started"+ )def get_tomorrow_at_time(hour: int) -> datetime.datetime: