瀏覽代碼

Allow for ".yaml" (#2244)

* allow for ".yaml"

* remove unused import
Justin Goette 3 年之前
父節點
當前提交
f91f4f0053
共有 3 個文件被更改,包括 9 次插入2 次删除
  1. 6 0
      frigate/app.py
  2. 2 2
      frigate/config.py
  3. 1 0
      frigate/const.py

+ 6 - 0
frigate/app.py

@@ -67,6 +67,12 @@ class FrigateApp:
 
     def init_config(self):
         config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")
+
+        # Check if we can use .yaml instead of .yml
+        config_file_yaml = config_file.replace(".yml", ".yaml")
+        if os.path.isfile(config_file_yaml):
+            config_file = config_file_yaml
+
         user_config = FrigateConfig.parse_file(config_file)
         self.config = user_config.runtime_config
 

+ 2 - 2
frigate/config.py

@@ -12,7 +12,7 @@ import yaml
 from pydantic import BaseModel, Extra, Field, validator
 from pydantic.fields import PrivateAttr
 
-from frigate.const import BASE_DIR, CACHE_DIR
+from frigate.const import BASE_DIR, CACHE_DIR, YAML_EXT
 from frigate.edgetpu import load_labels
 from frigate.util import create_mask, deep_merge
 
@@ -864,7 +864,7 @@ class FrigateConfig(FrigateBaseModel):
         with open(config_file) as f:
             raw_config = f.read()
 
-        if config_file.endswith(".yml"):
+        if config_file.endswith(YAML_EXT):
             config = yaml.safe_load(raw_config)
         elif config_file.endswith(".json"):
             config = json.loads(raw_config)

+ 1 - 0
frigate/const.py

@@ -2,3 +2,4 @@ BASE_DIR = "/media/frigate"
 CLIPS_DIR = f"{BASE_DIR}/clips"
 RECORD_DIR = f"{BASE_DIR}/recordings"
 CACHE_DIR = "/tmp/cache"
+YAML_EXT = (".yaml", ".yml")