Replace stringy paths with constants (#21247)

This commit is contained in:
Martin Weinelt 2025-12-12 14:22:09 +01:00 committed by GitHub
parent 649ca49e55
commit 67e18eff94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -21,7 +21,7 @@ from frigate.config.camera.updater import (
CameraConfigUpdateEnum, CameraConfigUpdateEnum,
CameraConfigUpdateSubscriber, CameraConfigUpdateSubscriber,
) )
from frigate.const import CONFIG_DIR from frigate.const import BASE_DIR, CONFIG_DIR
from frigate.models import User from frigate.models import User
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -371,7 +371,7 @@ class WebPushClient(Communicator):
sorted_objects.update(payload["after"]["data"]["sub_labels"]) sorted_objects.update(payload["after"]["data"]["sub_labels"])
image = f"{payload['after']['thumb_path'].replace('/media/frigate', '')}" image = f"{payload['after']['thumb_path'].replace(BASE_DIR, '')}"
ended = state == "end" or state == "genai" ended = state == "end" or state == "genai"
if state == "genai" and payload["after"]["data"]["metadata"]: if state == "genai" and payload["after"]["data"]["metadata"]:

View File

@ -14,6 +14,7 @@ from setproctitle import setproctitle
import frigate.log import frigate.log
from frigate.config.logger import LoggerConfig from frigate.config.logger import LoggerConfig
from frigate.const import CONFIG_DIR
class BaseProcess(mp.Process): class BaseProcess(mp.Process):
@ -92,7 +93,7 @@ class FrigateProcess(BaseProcess):
try: try:
import memray import memray
reports_dir = pathlib.Path("/config/memray_reports") reports_dir = pathlib.Path(CONFIG_DIR) / "memray_reports"
reports_dir.mkdir(parents=True, exist_ok=True) reports_dir.mkdir(parents=True, exist_ok=True)
safe_name = ( safe_name = (
process_name.replace(":", "_").replace("/", "_").replace("\\", "_") process_name.replace(":", "_").replace("/", "_").replace("\\", "_")
@ -126,7 +127,7 @@ class FrigateProcess(BaseProcess):
self.__memray_tracker.__exit__(None, None, None) self.__memray_tracker.__exit__(None, None, None)
self.__memray_tracker = None self.__memray_tracker = None
reports_dir = pathlib.Path("/config/memray_reports") reports_dir = pathlib.Path(CONFIG_DIR) / "memray_reports"
html_file = reports_dir / f"{safe_name}.html" html_file = reports_dir / f"{safe_name}.html"
result = subprocess.run( result = subprocess.run(