allow creating directories from camera snapshot, stream record, and tensorflow file out (#39728)
This commit is contained in:
parent
1ec3446c56
commit
1a78d96014
3 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@ from contextlib import suppress
|
|||
from datetime import timedelta
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
from random import SystemRandom
|
||||
|
||||
from aiohttp import web
|
||||
|
@ -660,6 +661,8 @@ async def async_handle_snapshot_service(camera, service):
|
|||
|
||||
def _write_image(to_file, image_data):
|
||||
"""Executor helper to write image."""
|
||||
if not os.path.exists(os.path.dirname(to_file)):
|
||||
os.makedirs(os.path.dirname(to_file), exist_ok=True)
|
||||
with open(to_file, "wb") as img_file:
|
||||
img_file.write(image_data)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""Provide functionality to record stream."""
|
||||
|
||||
import os
|
||||
import threading
|
||||
from typing import List
|
||||
|
||||
|
@ -17,6 +17,9 @@ def async_setup_recorder(hass):
|
|||
|
||||
def recorder_save_worker(file_out: str, segments: List[Segment], container_format: str):
|
||||
"""Handle saving stream."""
|
||||
if not os.path.exists(os.path.dirname(file_out)):
|
||||
os.makedirs(os.path.dirname(file_out), exist_ok=True)
|
||||
|
||||
first_pts = {"video": None, "audio": None}
|
||||
output = av.open(file_out, "w", format=container_format)
|
||||
output_v = None
|
||||
|
|
|
@ -328,6 +328,8 @@ class TensorFlowImageProcessor(ImageProcessingEntity):
|
|||
|
||||
for path in paths:
|
||||
_LOGGER.info("Saving results image to %s", path)
|
||||
if not os.path.exists(os.path.dirname(path)):
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
img.save(path)
|
||||
|
||||
def process_image(self, image):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue