From a1b70ad0791cceb4c70863a69d86c0f2d69b4ac4 Mon Sep 17 00:00:00 2001 From: lk-iqt <112730501+lk-iqt@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:21:57 -0500 Subject: [PATCH] File handling for gamutrf-offline --- gamutrf/offline.py | 2 ++ gamutrf/sample_reader.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/gamutrf/offline.py b/gamutrf/offline.py index 92584f34..a892972c 100644 --- a/gamutrf/offline.py +++ b/gamutrf/offline.py @@ -144,6 +144,8 @@ def main(): options = argument_parser().parse_args() filename = options.filename out_dir = os.path.dirname(filename) + if out_dir == "": + out_dir = "." _data_filename, _samples, meta = get_samples(filename) freq_start = int(meta["center_frequency"] - (meta["sample_rate"] / 2)) scan_args = { diff --git a/gamutrf/sample_reader.py b/gamutrf/sample_reader.py index 3dad8a74..ce171a3d 100644 --- a/gamutrf/sample_reader.py +++ b/gamutrf/sample_reader.py @@ -155,6 +155,11 @@ def get_samples(filename): meta = sigmf.sigmffile.fromfile(filename) data_filename = filename[:meta_ext] + if os.path.splitext(data_filename)[-1] != ".sigmf-data": + data_filename = data_filename + ".sigmf-data" + if not os.path.exists(data_filename): + raise FileNotFoundError(data_filename) + meta.set_data_file(data_filename) samples = meta.read_samples() global_meta = meta.get_global_info()