From c0bf5caaa34a4619ec96c2fa7b84bbc1553db937 Mon Sep 17 00:00:00 2001
From: Tamas Gal <himself@tamasgal.com>
Date: Tue, 20 Dec 2022 17:24:24 +0100
Subject: [PATCH] Dump corrupt data when overflow error is encountered

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

diff --git a/backend/scripts/ztplot.py b/backend/scripts/ztplot.py
index fbd95de..1cd99c8 100755
--- a/backend/scripts/ztplot.py
+++ b/backend/scripts/ztplot.py
@@ -209,7 +209,12 @@ class ZTPlot(kp.Module):
         except OverflowError:
             self.log.critical("OverflowError encountered when converting '%s' to "
                               "a datetime object.", utc_timestamp)
-            dt = "invalid date"
+            rawdata_filename = "/data/IO_EVT_overflowerror_{:08d}_{:08d}_FI{}_TC{}.dat".format(
+                    det_id, run_id, frame_index, trigger_counter)
+            self.log.critical("Dumping raw data to: %s and exiting.", rawdata_filename)
+            with open(rawdata_filename, "wb") as fobj:
+                fobj.write(raw_data)
+            exit(1)
 
         delta_t = (datetime.utcnow() - dt).seconds
         if abs(delta_t) > 60*5:
-- 
GitLab