From c93454bef6fd8af344099174e277987ba75d1abf Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Wed, 28 Mar 2018 08:51:20 +0200
Subject: [PATCH] Avoid crash in case of invalid binary data

---
 scripts/pmt_rates.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/scripts/pmt_rates.py b/scripts/pmt_rates.py
index d931786..23d69ca 100755
--- a/scripts/pmt_rates.py
+++ b/scripts/pmt_rates.py
@@ -121,7 +121,12 @@ class PMTRates(kp.Module):
         plt.close('all')
 
     def process(self, blob):
-        tmch_data = TMCHData(io.BytesIO(blob['CHData']))
+        try:
+            tmch_data = TMCHData(io.BytesIO(blob['CHData']))
+        except ValueError:
+            self.log.error("Could not parse binary data. Ignoring...")
+            return blob
+
         dom_id = tmch_data.dom_id
 
         if dom_id not in self.detector.doms:
-- 
GitLab