project reorganization: 1. executable files in bin directory now. 2. add recursive_unpack_targz.py for recursive unpacking specified in this script archives tar.gz with MVN data. 3. add asotr_unzip_plot.sh bash file for unpacking MVN data, collect asotr data into csv files and plot asotr MVN data. 4. add brd_wheel_1Hz_parser.py for demonstrate how to work with brd telemetry data

This commit is contained in:
Danila Gamkov
2025-06-06 10:54:25 +03:00
parent 2f37a7329b
commit b04009ad27
34 changed files with 2151 additions and 138 deletions

View File

@@ -0,0 +1,37 @@
import os
import tarfile
def extract_tar_gz(filepath, extract_dir):
""" Unpack archive in specified directory """
try:
with tarfile.open(filepath, "r:gz") as tar:
tar.extractall(path=extract_dir)
print(f"[+] Extracted: {filepath}")
except Exception as e:
print(f"[!] Error extracting {filepath}: {e}")
def should_extract(archive_path):
""" check exist directory's name without .tag.gs """
dirname = os.path.splitext(os.path.splitext(archive_path)[0])[0]
list_ignore = ['brd.tar.gz', 'aux_data.tar.gz', 'uvi.tar.gz', 'aux.tar.gz']
if all(elem not in archive_path for elem in list_ignore):
return not os.path.isdir(dirname)
def walk_and_extract(start_dir):
""" recursive directory traversal with unpacking """
for root, _, files in os.walk(start_dir):
for file in files:
if file.endswith(".tar.gz"):
archive_path = os.path.join(root, file)
target_dir = os.path.splitext(os.path.splitext(archive_path)[0])[0]
if should_extract(archive_path):
extract_tar_gz(archive_path, target_dir)
if __name__ == "__main__":
import sys
if len(sys.argv) != 2:
print("Usage: python recursive_unpack_targz.py /path/to/start/dir")
else:
walk_and_extract(sys.argv[1])