From fd59e81ce25a7a5c31eaaf2c21896da76c28da46 Mon Sep 17 00:00:00 2001 From: Steve <steved@ssec.wisc.edu> Date: Thu, 15 Oct 2015 21:39:09 +0000 Subject: [PATCH] bug fix, we were doing streams.remove(stream) inside a "for stream in streams:" which gave incorrect results --- edosl0util/merge.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/edosl0util/merge.py b/edosl0util/merge.py index 384fe4c..bb987b0 100644 --- a/edosl0util/merge.py +++ b/edosl0util/merge.py @@ -38,7 +38,8 @@ def merge(streams, output=sys.stdout): # streams are removed as they are exhausted while streams: - for stream in streams: + if 1: + stream = streams.pop(0) try: if last_packet is not None: LOG.debug("seeking to %s, %s", last_packet.stamp, last_packet.apid) @@ -74,23 +75,21 @@ def merge(streams, output=sys.stdout): while packets: pkt = packets.popleft() - LOG.debug('writing %s: %s', stream, pkt) output.write(pkt.bytes()) except PacketTooShort as err: LOG.error("corrupt stream, removing: %s", err) - streams.remove(stream) except NonConsecutiveSeqId: + steams.push(stream) LOG.debug('missing sequence id, next stream') except StopIteration: - streams.remove(stream) LOG.debug("end-of-stream %s", stream) - continue def merge_files(filepaths, destpath): filepaths, streams = make_streams(filepaths, fail_on_missing=True) - LOG.debug("merge order %s", filepaths) + for i in range(0, len(filepaths)): + LOG.debug("stream %s filepath %s", streams[i], filepaths[i]) merge(streams, output=io.open(destpath, 'wb')) -- GitLab