Prepared for playback engine
This commit is contained in:
14 files changed
+955
-189
No files matched your search
@@ -3,6 +3,7 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from datetime import datetime, timezone
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
from zipfile import ZIP_DEFLATED, ZipFile
|
||||
@@ -13,6 +14,8 @@ from dynalab_core.buffer import ValueBuffer
|
||||
from dynalab_core.errors import DLPakNoDataError
|
||||
from dynalab_core.protocols.packets.handshake import SignalDescriptor
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RecordManifest(BaseModel):
|
||||
timestamp: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
|
||||
@@ -62,6 +65,31 @@ class DLPak:
|
||||
|
||||
output_path = output_dir / file_path
|
||||
|
||||
with ZipFile(output_path, mode="w", compression=ZIP_DEFLATED) as archive:
|
||||
archive.writestr("manifest.json", self._manifest.model_dump_json(indent=2))
|
||||
archive.writestr("data.csv", self._data.export_csv())
|
||||
try:
|
||||
with ZipFile(output_path, mode="w", compression=ZIP_DEFLATED) as archive:
|
||||
archive.writestr(
|
||||
"manifest.json", self._manifest.model_dump_json(indent=2)
|
||||
)
|
||||
archive.writestr("data.csv", self._data.export_csv())
|
||||
except Exception as error:
|
||||
log.exception(
|
||||
"Failed to write DLPak archive to %s",
|
||||
output_path.name,
|
||||
extra={
|
||||
"event": "dlpak.write_failed",
|
||||
"output_filename": output_path.name,
|
||||
"exception_type": type(error).__name__,
|
||||
},
|
||||
)
|
||||
raise
|
||||
|
||||
log.info(
|
||||
"Wrote DLPak archive to %s",
|
||||
output_path.name,
|
||||
extra={
|
||||
"event": "dlpak.written",
|
||||
"output_filename": output_path.name,
|
||||
"sample_count": len(self._data),
|
||||
"signal_count": len(self._manifest.signals),
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user