mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-23 20:48:31 +03:00
fixes + ruff
This commit is contained in:
parent
bc7d321cc5
commit
d7d15b4886
@ -97,7 +97,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
self.object_recordings_info: dict[str, list] = defaultdict(list)
|
self.object_recordings_info: dict[str, list] = defaultdict(list)
|
||||||
self.audio_recordings_info: dict[str, list] = defaultdict(list)
|
self.audio_recordings_info: dict[str, list] = defaultdict(list)
|
||||||
self.end_time_cache: dict[str, Tuple[datetime.datetime, float]] = {}
|
self.end_time_cache: dict[str, Tuple[datetime.datetime, float]] = {}
|
||||||
self.unexpected_cache_files_seen: set[str] = set()
|
self.unexpected_cache_files_logged: bool = False
|
||||||
|
|
||||||
async def move_files(self) -> None:
|
async def move_files(self) -> None:
|
||||||
cache_files = [
|
cache_files = [
|
||||||
@ -116,9 +116,9 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
camera, date = basename.rsplit("@", maxsplit=1)
|
camera, date = basename.rsplit("@", maxsplit=1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if cache not in self.unexpected_cache_files_seen:
|
if not self.unexpected_cache_files_logged:
|
||||||
logger.warning(f"Skipping unexpected file in cache: {cache}")
|
logger.warning("Skipping unexpected files in cache")
|
||||||
self.unexpected_cache_files_seen.add(cache)
|
self.unexpected_cache_files_logged = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
start_time = datetime.datetime.strptime(
|
start_time = datetime.datetime.strptime(
|
||||||
@ -175,9 +175,9 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
camera, date = basename.rsplit("@", maxsplit=1)
|
camera, date = basename.rsplit("@", maxsplit=1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
if cache not in self.unexpected_cache_files_seen:
|
if not self.unexpected_cache_files_logged:
|
||||||
logger.warning(f"Skipping unexpected file in cache: {cache}")
|
logger.warning("Skipping unexpected files in cache")
|
||||||
self.unexpected_cache_files_seen.add(cache)
|
self.unexpected_cache_files_logged = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# important that start_time is utc because recordings are stored and compared in utc
|
# important that start_time is utc because recordings are stored and compared in utc
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
import sys
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
# Mock complex imports before importing maintainer
|
# Mock complex imports before importing maintainer
|
||||||
sys.modules["frigate.comms.inter_process"] = MagicMock()
|
sys.modules["frigate.comms.inter_process"] = MagicMock()
|
||||||
@ -10,8 +9,8 @@ sys.modules["frigate.comms.recordings_updater"] = MagicMock()
|
|||||||
sys.modules["frigate.config.camera.updater"] = MagicMock()
|
sys.modules["frigate.config.camera.updater"] = MagicMock()
|
||||||
|
|
||||||
# Now import the class under test
|
# Now import the class under test
|
||||||
from frigate.record.maintainer import RecordingMaintainer
|
from frigate.config import FrigateConfig # noqa: E402
|
||||||
from frigate.config import FrigateConfig
|
from frigate.record.maintainer import RecordingMaintainer # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
class TestMaintainer(unittest.IsolatedAsyncioTestCase):
|
class TestMaintainer(unittest.IsolatedAsyncioTestCase):
|
||||||
@ -54,13 +53,12 @@ class TestMaintainer(unittest.IsolatedAsyncioTestCase):
|
|||||||
for c in warn.call_args_list
|
for c in warn.call_args_list
|
||||||
if c.args
|
if c.args
|
||||||
and isinstance(c.args[0], str)
|
and isinstance(c.args[0], str)
|
||||||
and "Skipping unexpected file in cache: bad_filename.mp4"
|
and "Skipping unexpected files in cache" in c.args[0]
|
||||||
in c.args[0]
|
|
||||||
]
|
]
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
1,
|
1,
|
||||||
len(matching),
|
len(matching),
|
||||||
f"Expected a single warning for bad filename, got {len(matching)}",
|
f"Expected a single warning for unexpected files, got {len(matching)}",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user