From 45380b8919d09e5836adc6c746ae459fb1bea1ac Mon Sep 17 00:00:00 2001 From: Connor Colombo Date: Thu, 2 Mar 2023 13:54:31 -0500 Subject: [PATCH] GDS: FileManager skeleton added. --- .../IrisBackendv3/codec/files/__init__.py | 0 .../IrisBackendv3/codec/files/file.py | 27 +++++++++++++++++++ .../IrisBackendv3/codec/files/file_manager.py | 15 +++++++++++ .../IrisBackendv3/codec/files/image.py | 7 +++++ 4 files changed, 49 insertions(+) create mode 100644 Apps/GroundSoftware/IrisBackendv3/codec/files/__init__.py create mode 100644 Apps/GroundSoftware/IrisBackendv3/codec/files/file.py create mode 100644 Apps/GroundSoftware/IrisBackendv3/codec/files/file_manager.py create mode 100644 Apps/GroundSoftware/IrisBackendv3/codec/files/image.py diff --git a/Apps/GroundSoftware/IrisBackendv3/codec/files/__init__.py b/Apps/GroundSoftware/IrisBackendv3/codec/files/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/Apps/GroundSoftware/IrisBackendv3/codec/files/file.py b/Apps/GroundSoftware/IrisBackendv3/codec/files/file.py new file mode 100644 index 000000000..786a34337 --- /dev/null +++ b/Apps/GroundSoftware/IrisBackendv3/codec/files/file.py @@ -0,0 +1,27 @@ +from typing import TypeAlias, Dict, List, Final, ClassVar + +from dataclasses import dataclass + +from ..payload import FileMetadata, FileBlockPayload + +HashedId: TypeAlias = int + +class File: + _FILE_EXT: ClassVar[str] = '.iris.hex' + + _metadata: FileMetadata + + _blocks: Dict[int, FileBlockPayload] + + @property + def hashedId(self) -> HashedId: + return self._metadata.hashedId + + def ingest_block(block: FileBlockPayload) -> None: + pass + + def generate_file_contents() -> bytes: + # TODO: Make a cached property? + pass + + def save_file(self, path: str) \ No newline at end of file diff --git a/Apps/GroundSoftware/IrisBackendv3/codec/files/file_manager.py b/Apps/GroundSoftware/IrisBackendv3/codec/files/file_manager.py new file mode 100644 index 000000000..2baf421ca --- /dev/null +++ b/Apps/GroundSoftware/IrisBackendv3/codec/files/file_manager.py @@ -0,0 +1,15 @@ +from typing import TypeAlias, Dict, List + +from .file import File, HashedId +from ..packet import Packet + +class FileManager: + in_progress_files: Dict[HashedId, File] + + def process_packet(packet: Packet) -> bool: + """ Extracts any file blocks from the given packet and uses them to + build or continue building a file. + """ + raise NotImplementedError() + + def save_all_files() diff --git a/Apps/GroundSoftware/IrisBackendv3/codec/files/image.py b/Apps/GroundSoftware/IrisBackendv3/codec/files/image.py new file mode 100644 index 000000000..9d748d918 --- /dev/null +++ b/Apps/GroundSoftware/IrisBackendv3/codec/files/image.py @@ -0,0 +1,7 @@ +from .file import File + +class Image(File): + # override save + + def to_b64(self) -> str: + pass