From 6b15ec8a3689bcf2f4b5bd8ed5451243c2abfbe6 Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Wed, 22 May 2019 00:06:28 +0200
Subject: [PATCH] Be flexible with ahrs plots

---
 app/routes.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/app/routes.py b/app/routes.py
index 1123437..4d72f36 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -1,4 +1,5 @@
-from os.path import join, exists
+from glob import glob
+from os.path import basename, join, exists
 from functools import wraps
 import toml
 from flask import render_template, send_from_directory, request, Response
@@ -13,7 +14,7 @@ app.config['FREEZER_DESTINATION'] = '../km3web'
 PLOTS = [['dom_activity', 'dom_rates'], ['pmt_rates', 'pmt_hrv'],
          ['trigger_rates'], ['ztplot', 'triggermap']]
 
-AHRS_PLOTS = [['yaw_calib'], ['pitch_calib'], ['roll_calib']]
+AHRS_PLOTS = [['yaw_calib_du*'], ['pitch_calib_du*'], ['roll_calib_du*']]
 TRIGGER_PLOTS = [['trigger_rates'], ['trigger_rates_lin']]
 K40_PLOTS = [['intradom'], ['angular_k40rate_distribution']]
 RTTC_PLOTS = [['rttc']]
@@ -82,7 +83,14 @@ def index():
 @app.route('/ahrs.html')
 @requires_auth
 def ahrs():
-    return render_template('plots.html', plots=AHRS_PLOTS)
+    plots = []
+    for row in AHRS_PLOTS:
+        if not isinstance(row, list) and '*' in row:
+            plots.append(
+                sorted([basename(p) for p in glob(join(PLOTS_PATH, row))]))
+        else:
+            plots.append(row)
+    return render_template('plots.html', plots=plots)
 
 
 @app.route('/reco.html')
@@ -90,11 +98,13 @@ def ahrs():
 def reco():
     return render_template('plots.html', plots=RECO_PLOTS)
 
+
 @app.route('/sn.html')
 @requires_auth
 def supernova():
     return render_template('plots.html', plots=SN_PLOTS)
 
+
 @app.route('/compact.html')
 @requires_auth
 def compact():
-- 
GitLab