Skip to content

Commit

Permalink
chore: require python 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 9, 2024
1 parent f008537 commit c34106d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 89 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
Expand Down
81 changes: 2 additions & 79 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ packages = [
uiprotect = "uiprotect.cli:app"

[tool.poetry.dependencies]
python = "^3.8"
python = ">=3.10"
rich = ">=10"
typer = {version = ">0.6", extras = ["all"]}
async-timeout = ">=3.0.1"
Expand All @@ -47,7 +47,6 @@ pytest = "^7.0"
pytest-cov = "^3.0"
aiosqlite = ">=0.20.0"
asttokens = "^2.4.1"
asyncify = "^0.10.0"
pytest-asyncio = "^0.23.7"
pytest-benchmark = "^4.0.0"
pytest-sugar = "^1.0.0"
Expand Down
20 changes: 13 additions & 7 deletions src/uiprotect/cli/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import av
import dateparser
import typer
from asyncify import asyncify
from PIL import Image
from rich.progress import (
BarColumn,
Expand Down Expand Up @@ -687,7 +686,6 @@ async def _download_watcher(
return downloaded


@asyncify
def _verify_thumbnail(path: Path) -> bool:
try:
image = Image.open(path)
Expand Down Expand Up @@ -731,7 +729,13 @@ async def _download_event_thumb(
await aos.makedirs(thumb_path.parent, exist_ok=True)
await aos.rename(existing_thumb_path, thumb_path)

if verify and thumb_path.exists() and not await _verify_thumbnail(thumb_path):
if (
verify
and thumb_path.exists()
and not await asyncio.get_running_loop().run_in_executor(
None, _verify_thumbnail, thumb_path
)
):
_LOGGER.warning(
"Corrupted event %s file for event (%s), redownloading",
thumb_type,
Expand Down Expand Up @@ -761,7 +765,6 @@ async def _download_event_thumb(
return False


@asyncify
def _verify_video_file( # type: ignore[return]
path: Path,
length: float,
Expand Down Expand Up @@ -789,7 +792,6 @@ def _verify_video_file( # type: ignore[return]
return False, False


@asyncify
def _add_metadata(path: Path, creation: datetime, title: str) -> bool:
creation = local_datetime(creation)
output_path = path.parent / path.name.replace(".mp4", ".metadata.mp4")
Expand Down Expand Up @@ -863,7 +865,9 @@ async def _download_event_video(
if verify and event_path.exists():
valid = False
if event.end is not None:
valid, metadata_valid = await _verify_video_file(
valid, metadata_valid = await asyncio.get_running_loop().run_in_executor(
None,
_verify_video_file,
event_path,
(event.end - event.start).total_seconds(),
camera.channels[0].width,
Expand Down Expand Up @@ -894,7 +898,9 @@ async def _download_event_video(

if (downloaded or not metadata_valid) and event.end is not None:
file_context = event.get_file_context(ctx)
if not await _add_metadata(event_path, event.start, file_context["title"]):
if not await asyncio.get_running_loop().run_in_executor(
None, _add_metadata, event_path, event.start, file_context["title"]
):
_LOGGER.warning("Failed to write metadata for event (%s)", event.id)
return downloaded

Expand Down

0 comments on commit c34106d

Please sign in to comment.