From 6eb4f69d304d1d4f3dec10586eabde0495c05e42 Mon Sep 17 00:00:00 2001
From: Bruce Flynn <brucef@ssec.wisc.edu>
Date: Wed, 14 Oct 2015 18:56:33 +0000
Subject: [PATCH] Handle PacketTooShort in edosl0info

---
 edosl0util/cli.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/edosl0util/cli.py b/edosl0util/cli.py
index b283aa9..e100380 100644
--- a/edosl0util/cli.py
+++ b/edosl0util/cli.py
@@ -59,10 +59,20 @@ def cmd_info():
     args = parser.parse_args()
     _configure_logging(args)
 
+    num_packets = 0
     packets = stream.PacketStream(io.open(args.filepath, 'rb'))
     first = datetime(3000, 1, 1)
     last = datetime(1970, 1, 1)
-    for packet in packets:
+    while True:
+        try:
+            packet = packets.next()
+            num_packets += 1
+        except stream.PacketTooShort as err:
+            LOG.warn("corrupt packet stream after %d packets: %s",
+                     num_packets, err)
+            break
+        except StopIteration:
+            break
         if packet.stamp:
             first = min(packet.stamp, first)
             last = max(packet.stamp, last)
-- 
GitLab