From 96e402e32aac70ff725494f66600adbf92994f00 Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Mon, 25 Nov 2019 02:26:52 +0100
Subject: [PATCH] Add ELOG support for ztplots

---
 requirements.txt  | 2 +-
 scripts/ztplot.py | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/requirements.txt b/requirements.txt
index 98e10da..2200eed 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-km3pipe>=8.24.3
+km3pipe>=8.25.0
 flask
 frozen-flask
 gunicorn
diff --git a/scripts/ztplot.py b/scripts/ztplot.py
index 40e94c4..7424e40 100755
--- a/scripts/ztplot.py
+++ b/scripts/ztplot.py
@@ -21,6 +21,7 @@ from __future__ import division
 import km3pipe.style
 from km3modules.plot import ztplot
 from km3modules.common import LocalDBService
+from km3modules.communication import ELOGService
 from km3pipe.io.daq import is_3dmuon, is_3dshower, is_mxshower
 import km3pipe as kp
 import numpy as np
@@ -50,6 +51,7 @@ class ZTPlot(kp.Module):
         self.det_id = self.require('det_id')
         self.event_selection_table = self.get('event_selection_table',
                                               default='event_selection')
+        self.logbook = self.get('logbook', default="Individual+Logbooks")
         self.t0set = None
         self.calib = None
         self.max_z = None
@@ -213,6 +215,12 @@ class ZTPlot(kp.Module):
             ])
             shutil.copy(f, plot_filename)
             self._update_lower_limits()
+            self['services']['post_elog'](
+                logbook=self.logbook,
+                subject="New massive event!",
+                message="A new event has made it into the top 10!",
+                author="Gal T",
+                files=[plot_filename])
 
         plt.close(fig)
         plt.close('all')
@@ -233,6 +241,7 @@ def main():
 
     pipe = kp.Pipeline()
     pipe.attach(LocalDBService, thread_safety=False)
+    pipe.attach(ELOGService)
     pipe.attach(kp.io.ch.CHPump,
                 host=ligier_ip,
                 port=ligier_port,
-- 
GitLab