diff --git a/edosl0util/cli/trunc.py b/edosl0util/cli/trunc.py index 79c5522d74161584b30ef0b604dd746165618fd3..7b1ae976ebf8934e8ba03ecf475e8217378deeda 100644 --- a/edosl0util/cli/trunc.py +++ b/edosl0util/cli/trunc.py @@ -1,6 +1,7 @@ import os import io from edosl0util.cli import util +from edosl0util import stream from edosl0util import trunc @@ -10,12 +11,14 @@ def main(): parser.add_argument("filename") parser.add_argument("start", type=util.timestamp, help="YYYY-MM-DD HH:MM:SS") parser.add_argument("end", type=util.timestamp, help="YYYY-MM-DD HH:MM:SS") + parser.add_argument("-a", "--aqua", action="store_true", help="Stream is Aqua data") args = parser.parse_args() util.configure_logging(args) + stream_impl = stream.aqua_packet_stream if args.aqua else stream.jpss_packet_stream output = args.output or os.path.basename(args.filename) + ".trunc" with io.open(output, "wb") as fptr: - for pkt in trunc.trunc_file(args.filename, args.start, args.end): + for pkt in trunc.trunc_file(args.filename, args.start, args.end, stream_impl=stream_impl): fptr.write(pkt.bytes()) diff --git a/edosl0util/trunc.py b/edosl0util/trunc.py index a0674e62a75e2991fcf87f60ade3467d0d25766d..6e6f8af29f772e2e3118c209964bfcae3022b179 100644 --- a/edosl0util/trunc.py +++ b/edosl0util/trunc.py @@ -19,6 +19,6 @@ def trunc_stream(stream, start, end): pkt = stream.next() -def trunc_file(filename, start, end): - stream = jpss_packet_stream(io.open(filename, "rb")) +def trunc_file(filename, start, end, stream_impl=jpss_packet_stream): + stream = stream_impl(io.open(filename, "rb")) return trunc_stream(stream, start, end)