Allow creation of avi video.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Mikaël Capelle
2024-12-15 13:37:17 +01:00
parent bc06f86fdc
commit 8308940674
6 changed files with 207 additions and 136 deletions

View File

@@ -1,3 +1,4 @@
import os
from pathlib import Path
from typing import Final
@@ -9,9 +10,14 @@ class FileHandlerAPI(FileHandler):
def __init__(self, folder: Path):
self.folder: Final = folder
def create(self, filename: str, content: bytes, text: bool = False):
self.folder.mkdir(exist_ok=True)
with open(self.folder.joinpath(filename), "wb") as fp:
fp.write(content)
dump_api_message("file", {"filename": filename, "size": len(content)})
def make_path(self, filename: str) -> Path:
return self.folder.joinpath(filename)
def notify_created(self, path: Path):
dump_api_message("file", {"filename": path.name, "size": os.stat(path).st_size})
def _create(self, path: Path, content: bytes, text: bool = False):
self.folder.mkdir(exist_ok=True)
with open(path, "wb") as fp:
fp.write(content)
return path

View File

@@ -10,12 +10,17 @@ class SimpleFileHandler(FileHandler):
self.logger: Final = logger
self.folder: Final = folder
def create(self, filename: str, content: bytes, text: bool = False):
def make_path(self, filename: str) -> Path:
return self.folder.joinpath(filename)
def notify_created(self, path: Path): ...
def _create(self, path: Path, content: bytes, text: bool = False):
if text:
for line in content.decode("utf-8").splitlines():
self.logger.info(line)
else:
self.folder.mkdir(exist_ok=True)
with open(self.folder.joinpath(filename), "wb") as fp:
with open(path, "wb") as fp:
fp.write(content)
return self.folder.joinpath(filename)
return path