Skip to content
Snippets Groups Projects
Commit fd59e81c authored by Steve Dutcher's avatar Steve Dutcher
Browse files

bug fix, we were doing streams.remove(stream) inside a "for stream in...

bug fix, we were doing streams.remove(stream) inside a "for stream in streams:" which gave incorrect results
parent 01fc7dcc
No related branches found
No related tags found
No related merge requests found
......@@ -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'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment