diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-06-28 03:22:30 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-06-30 03:47:49 +0300 |
commit | 8f20c9b825cabab7a3f0f5dd2cfe000cc7f72c28 (patch) | |
tree | b5d7446e7b2fcfd42b1e5029aeef33ecb5f9715f /src/home/media | |
parent | ee09bc98aedfc6a65a5026432b399345a30a39c8 (diff) |
polaris pwk 1725cgld full support
- significant improvements, correctnesses and stability fixes in
protocol implementation
- correct handling of device appearances and disappearances
- flawlessly functioning telegram bot that re-renders kettle's state
(temperature and other) in real time
Diffstat (limited to 'src/home/media')
-rw-r--r-- | src/home/media/node_client.py | 6 | ||||
-rw-r--r-- | src/home/media/record.py | 6 | ||||
-rw-r--r-- | src/home/media/record_client.py | 18 | ||||
-rw-r--r-- | src/home/media/storage.py | 4 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/home/media/node_client.py b/src/home/media/node_client.py index 4430962..eb39898 100644 --- a/src/home/media/node_client.py +++ b/src/home/media/node_client.py @@ -2,7 +2,7 @@ import requests import shutil import logging -from typing import Optional, Union +from typing import Optional, Union, List from .storage import RecordFile from ..util import Addr from ..api.errors import ApiResponseError @@ -25,7 +25,7 @@ class MediaNodeClient: def record_download(self, record_id: int, output: str): return self._call(f'record/download/{record_id}/', save_to=output) - def storage_list(self, extended=False, as_objects=False) -> Union[list[str], list[dict], list[RecordFile]]: + def storage_list(self, extended=False, as_objects=False) -> Union[List[str], List[dict], List[RecordFile]]: r = self._call('storage/list/', params={'extended': int(extended)}) files = r['files'] if as_objects: @@ -33,7 +33,7 @@ class MediaNodeClient: return files @staticmethod - def record_list_from_serialized(files: Union[list[str], list[dict]]): + def record_list_from_serialized(files: Union[List[str], List[dict]]): new_files = [] for f in files: kwargs = {'remote': True} diff --git a/src/home/media/record.py b/src/home/media/record.py index fdb8382..cd7447a 100644 --- a/src/home/media/record.py +++ b/src/home/media/record.py @@ -5,7 +5,7 @@ import time import subprocess import signal -from typing import Optional +from typing import Optional, List, Dict from ..util import find_child_processes, Addr from ..config import config from .storage import RecordFile, RecordStorage @@ -22,7 +22,7 @@ class RecordHistoryItem: request_time: float start_time: float stop_time: float - relations: list[int] + relations: List[int] status: RecordStatus error: Optional[Exception] file: Optional[RecordFile] @@ -76,7 +76,7 @@ class RecordingNotFoundError(Exception): class RecordHistory: - history: dict[int, RecordHistoryItem] + history: Dict[int, RecordHistoryItem] def __init__(self): self.history = {} diff --git a/src/home/media/record_client.py b/src/home/media/record_client.py index f264155..322495c 100644 --- a/src/home/media/record_client.py +++ b/src/home/media/record_client.py @@ -7,7 +7,7 @@ from tempfile import gettempdir from .record import RecordStatus from .node_client import SoundNodeClient, MediaNodeClient, CameraNodeClient from ..util import Addr -from typing import Optional, Callable +from typing import Optional, Callable, Dict class RecordClient: @@ -15,14 +15,14 @@ class RecordClient: interrupted: bool logger: logging.Logger - clients: dict[str, MediaNodeClient] - awaiting: dict[str, dict[int, Optional[dict]]] + clients: Dict[str, MediaNodeClient] + awaiting: Dict[str, Dict[int, Optional[dict]]] error_handler: Optional[Callable] finished_handler: Optional[Callable] download_on_finish: bool def __init__(self, - nodes: dict[str, Addr], + nodes: Dict[str, Addr], error_handler: Optional[Callable] = None, finished_handler: Optional[Callable] = None, download_on_finish=False): @@ -50,7 +50,7 @@ class RecordClient: self.stop() self.logger.exception(exc) - def make_clients(self, nodes: dict[str, Addr]): + def make_clients(self, nodes: Dict[str, Addr]): pass def stop(self): @@ -148,9 +148,9 @@ class RecordClient: class SoundRecordClient(RecordClient): DOWNLOAD_EXTENSION = 'mp3' - # clients: dict[str, SoundNodeClient] + # clients: Dict[str, SoundNodeClient] - def make_clients(self, nodes: dict[str, Addr]): + def make_clients(self, nodes: Dict[str, Addr]): for node, addr in nodes.items(): self.clients[node] = SoundNodeClient(addr) self.awaiting[node] = {} @@ -158,9 +158,9 @@ class SoundRecordClient(RecordClient): class CameraRecordClient(RecordClient): DOWNLOAD_EXTENSION = 'mp4' - # clients: dict[str, CameraNodeClient] + # clients: Dict[str, CameraNodeClient] - def make_clients(self, nodes: dict[str, Addr]): + def make_clients(self, nodes: Dict[str, Addr]): for node, addr in nodes.items(): self.clients[node] = CameraNodeClient(addr) self.awaiting[node] = {}
\ No newline at end of file diff --git a/src/home/media/storage.py b/src/home/media/storage.py index 08ba06a..dd74ff8 100644 --- a/src/home/media/storage.py +++ b/src/home/media/storage.py @@ -3,7 +3,7 @@ import re import shutil import logging -from typing import Optional, Union +from typing import Optional, Union, List from datetime import datetime from ..util import strgen @@ -149,7 +149,7 @@ class RecordStorage: self.root = root - def getfiles(self, as_objects=False) -> Union[list[str], list[RecordFile]]: + def getfiles(self, as_objects=False) -> Union[List[str], List[RecordFile]]: files = [] for name in os.listdir(self.root): path = os.path.join(self.root, name) |