mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-30 13:48:07 +02:00
Improve config validation error messages (#11292)
This commit is contained in:
parent
3ed89ec042
commit
2be15b6c01
@ -16,6 +16,7 @@ import psutil
|
|||||||
from peewee_migrate import Router
|
from peewee_migrate import Router
|
||||||
from playhouse.sqlite_ext import SqliteExtDatabase
|
from playhouse.sqlite_ext import SqliteExtDatabase
|
||||||
from playhouse.sqliteq import SqliteQueueDatabase
|
from playhouse.sqliteq import SqliteQueueDatabase
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
from frigate.api.app import create_app
|
from frigate.api.app import create_app
|
||||||
from frigate.comms.config_updater import ConfigPublisher
|
from frigate.comms.config_updater import ConfigPublisher
|
||||||
@ -611,8 +612,13 @@ class FrigateApp:
|
|||||||
print("*************************************************************")
|
print("*************************************************************")
|
||||||
print("*** Config Validation Errors ***")
|
print("*** Config Validation Errors ***")
|
||||||
print("*************************************************************")
|
print("*************************************************************")
|
||||||
print(e)
|
if isinstance(e, ValidationError):
|
||||||
print(traceback.format_exc())
|
for error in e.errors():
|
||||||
|
location = ".".join(str(item) for item in error["loc"])
|
||||||
|
print(f"{location}: {error['msg']}")
|
||||||
|
else:
|
||||||
|
print(e)
|
||||||
|
print(traceback.format_exc())
|
||||||
print("*************************************************************")
|
print("*************************************************************")
|
||||||
print("*** End Config Validation Errors ***")
|
print("*** End Config Validation Errors ***")
|
||||||
print("*************************************************************")
|
print("*************************************************************")
|
||||||
|
@ -555,19 +555,24 @@ class ZoneConfig(BaseModel):
|
|||||||
# old native resolution coordinates
|
# old native resolution coordinates
|
||||||
if isinstance(coordinates, list):
|
if isinstance(coordinates, list):
|
||||||
explicit = any(p.split(",")[0] > "1.0" for p in coordinates)
|
explicit = any(p.split(",")[0] > "1.0" for p in coordinates)
|
||||||
self._contour = np.array(
|
try:
|
||||||
[
|
self._contour = np.array(
|
||||||
(
|
[
|
||||||
[int(p.split(",")[0]), int(p.split(",")[1])]
|
(
|
||||||
if explicit
|
[int(p.split(",")[0]), int(p.split(",")[1])]
|
||||||
else [
|
if explicit
|
||||||
int(float(p.split(",")[0]) * frame_shape[1]),
|
else [
|
||||||
int(float(p.split(",")[1]) * frame_shape[0]),
|
int(float(p.split(",")[0]) * frame_shape[1]),
|
||||||
]
|
int(float(p.split(",")[1]) * frame_shape[0]),
|
||||||
)
|
]
|
||||||
for p in coordinates
|
)
|
||||||
]
|
for p in coordinates
|
||||||
)
|
]
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid coordinates found in configuration file. Coordinates must be relative (between 0-1): {coordinates}"
|
||||||
|
)
|
||||||
|
|
||||||
if explicit:
|
if explicit:
|
||||||
self.coordinates = ",".join(
|
self.coordinates = ",".join(
|
||||||
@ -579,19 +584,24 @@ class ZoneConfig(BaseModel):
|
|||||||
elif isinstance(coordinates, str):
|
elif isinstance(coordinates, str):
|
||||||
points = coordinates.split(",")
|
points = coordinates.split(",")
|
||||||
explicit = any(p > "1.0" for p in points)
|
explicit = any(p > "1.0" for p in points)
|
||||||
self._contour = np.array(
|
try:
|
||||||
[
|
self._contour = np.array(
|
||||||
(
|
[
|
||||||
[int(points[i]), int(points[i + 1])]
|
(
|
||||||
if explicit
|
[int(points[i]), int(points[i + 1])]
|
||||||
else [
|
if explicit
|
||||||
int(float(points[i]) * frame_shape[1]),
|
else [
|
||||||
int(float(points[i + 1]) * frame_shape[0]),
|
int(float(points[i]) * frame_shape[1]),
|
||||||
]
|
int(float(points[i + 1]) * frame_shape[0]),
|
||||||
)
|
]
|
||||||
for i in range(0, len(points), 2)
|
)
|
||||||
]
|
for i in range(0, len(points), 2)
|
||||||
)
|
]
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid coordinates found in configuration file. Coordinates must be relative (between 0-1): {coordinates}"
|
||||||
|
)
|
||||||
|
|
||||||
if explicit:
|
if explicit:
|
||||||
self.coordinates = ",".join(
|
self.coordinates = ",".join(
|
||||||
|
Loading…
Reference in New Issue
Block a user