mirror of
https://github.com/alexhopeoconnor/frigate.git
synced 2026-10-03 19:12:00 +10:00
* Pin ruff * Add python upgrade fixes This enables python upgrade checks in ruff to look for deprecated types and patterns. This namely fixes: - usage of deprecated `Typing` which is now built in - some specific exceptions which are caught and have new aliases Some specific UP checks were also ignored as they are stylistic / unimportant and likely to cause bugs * Remove async blocking calls Use asyncio.to_thread on two remaining blocking calls to fix hanging event thread loop. Enable this specific rule to block it in the future. * Use proper logging mechanism * Correctly format logs * Raise with context When raising an exception include the from context to improve debugging * Cleanup
83 lines
2.0 KiB
Python
83 lines
2.0 KiB
Python
from enum import Enum
|
|
|
|
from pydantic import Field
|
|
|
|
from ..base import FrigateBaseModel
|
|
|
|
__all__ = [
|
|
"TimestampStyleConfig",
|
|
"TimestampEffectEnum",
|
|
"ColorConfig",
|
|
"TimestampPositionEnum",
|
|
]
|
|
|
|
|
|
# TODO: Identify what the default format to display timestamps is
|
|
DEFAULT_TIME_FORMAT = "%m/%d/%Y %H:%M:%S"
|
|
# German Style:
|
|
# DEFAULT_TIME_FORMAT = "%d.%m.%Y %H:%M:%S"
|
|
|
|
|
|
class TimestampPositionEnum(str, Enum):
|
|
tl = "tl"
|
|
tr = "tr"
|
|
bl = "bl"
|
|
br = "br"
|
|
|
|
|
|
class ColorConfig(FrigateBaseModel):
|
|
red: int = Field(
|
|
default=255,
|
|
ge=0,
|
|
le=255,
|
|
title="Red",
|
|
description="Red component (0-255) for timestamp color.",
|
|
)
|
|
green: int = Field(
|
|
default=255,
|
|
ge=0,
|
|
le=255,
|
|
title="Green",
|
|
description="Green component (0-255) for timestamp color.",
|
|
)
|
|
blue: int = Field(
|
|
default=255,
|
|
ge=0,
|
|
le=255,
|
|
title="Blue",
|
|
description="Blue component (0-255) for timestamp color.",
|
|
)
|
|
|
|
|
|
class TimestampEffectEnum(str, Enum):
|
|
solid = "solid"
|
|
shadow = "shadow"
|
|
|
|
|
|
class TimestampStyleConfig(FrigateBaseModel):
|
|
position: TimestampPositionEnum = Field(
|
|
default=TimestampPositionEnum.tl,
|
|
title="Timestamp position",
|
|
description="Position of the timestamp on the image (tl/tr/bl/br).",
|
|
)
|
|
format: str = Field(
|
|
default=DEFAULT_TIME_FORMAT,
|
|
title="Timestamp format",
|
|
description="Datetime format string used for timestamps (Python datetime format codes).",
|
|
)
|
|
color: ColorConfig = Field(
|
|
default_factory=ColorConfig,
|
|
title="Timestamp color",
|
|
description="RGB color values for the timestamp text (all values 0-255).",
|
|
)
|
|
thickness: int = Field(
|
|
default=2,
|
|
title="Timestamp thickness",
|
|
description="Line thickness of the timestamp text.",
|
|
)
|
|
effect: TimestampEffectEnum | None = Field(
|
|
default=None,
|
|
title="Timestamp effect",
|
|
description="Visual effect for the timestamp text (none, solid, shadow).",
|
|
)
|