Compare commits
No commits in common. "353f073d12c2fc2eadefe209e7c0179470888333" and "a6475f2c3bd24834f5c1eeba63984b03b353517b" have entirely different histories.
353f073d12
...
a6475f2c3b
@ -128,7 +128,7 @@ add_global_links:
|
||||
- {"text": "show recent events on map",
|
||||
"URL": "https://fdsnws.geophysik.ruhr-uni-bochum.de/map/?lat=39.5&lon=21&zoom=7&baselayer=mapnik"}
|
||||
|
||||
# html logo at page bottom (path relative to html directory)
|
||||
# html logo at page bottom
|
||||
html_logo: "figures/Logo_RUB_BLAU_rgb.png"
|
||||
|
||||
# E-mail notifications
|
||||
|
11
survBot.py
11
survBot.py
@ -504,21 +504,12 @@ class SurveillanceBot(object):
|
||||
|
||||
outfile.write(finish_html_table())
|
||||
|
||||
# add optional links below html table
|
||||
for dct in self.add_global_links:
|
||||
link_str = get_html_link(dct.get('text'), dct.get('URL'))
|
||||
outfile.write(get_html_text(link_str))
|
||||
|
||||
# add status message
|
||||
outfile.write(get_html_text(self.status_message))
|
||||
|
||||
# write footer with optional logo
|
||||
logo_file = self.parameters.get('html_logo')
|
||||
if not os.path.isfile(pjoin(self.outpath_html, logo_file)):
|
||||
print(f'Specified file {logo_file} not found.')
|
||||
logo_file = None
|
||||
|
||||
outfile.write(html_footer(footer_logo=logo_file))
|
||||
outfile.write(html_footer(footer_logo=self.parameters.get('html_logo')))
|
||||
|
||||
except Exception as e:
|
||||
print(f'Could not write HTML table to {fnout}:')
|
||||
|
31
utils.py
31
utils.py
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from functools import partial
|
||||
|
||||
import matplotlib
|
||||
import numpy as np
|
||||
|
||||
@ -34,17 +36,17 @@ def get_bg_color(check_key, status, dt_thresh=None, hex=False):
|
||||
|
||||
|
||||
def get_color(key):
|
||||
# some old GUI default colors
|
||||
# colors_dict = {'FAIL': (255, 85, 50, 255),
|
||||
# some GUI default colors
|
||||
# colors_dict = {'FAIL': (255, 50, 0, 255),
|
||||
# 'NO DATA': (255, 255, 125, 255),
|
||||
# 'WARN': (255, 255, 80, 255),
|
||||
# 'OK': (173, 255, 133, 255),
|
||||
# 'OK': (125, 255, 125, 255),
|
||||
# 'undefined': (230, 230, 230, 255),
|
||||
# 'disc': (255, 160, 40, 255),}
|
||||
colors_dict = {'FAIL': (195, 29, 14, 255),
|
||||
'NO DATA': (255, 255, 125, 255),
|
||||
'WARN': (250, 192, 63, 255),
|
||||
'OK': (185, 245, 145, 255),
|
||||
'WARN': (249, 238, 139, 255),
|
||||
'OK': (179, 219, 153, 255),
|
||||
'undefined': (240, 240, 240, 255),
|
||||
'disc': (126, 127, 131, 255), }
|
||||
return colors_dict.get(key)
|
||||
@ -65,11 +67,18 @@ def get_time_delay_color(dt, dt_thresh):
|
||||
return get_color('FAIL')
|
||||
|
||||
|
||||
def get_warn_color(count, n_colors=20):
|
||||
if count > n_colors:
|
||||
count = -1
|
||||
gradient = np.linspace((240, 245, 110, 255), (250, 192, 63, 255), n_colors, dtype=int)
|
||||
return tuple(gradient[count])
|
||||
def get_warn_color(count):
|
||||
n_colors = 20
|
||||
# r = np.linspace(158, 255, n_colors, dtype=int)
|
||||
# g = np.linspace(255, 255, n_colors, dtype=int)
|
||||
# b = np.linspace(114, 80, n_colors, dtype=int)
|
||||
r = np.linspace(204, 249, n_colors, dtype=int)
|
||||
g = np.linspace(226, 238, n_colors, dtype=int)
|
||||
b = np.linspace(149, 139, n_colors, dtype=int)
|
||||
pad = partial(np.pad, pad_width=(0, 100), mode='edge')
|
||||
r, g, b = map(pad, [r, g, b])
|
||||
color = (r[count], g[count], b[count], 255)
|
||||
return color
|
||||
|
||||
|
||||
def get_mass_color(message):
|
||||
@ -245,4 +254,4 @@ def plot_threshold_lines(fig, channel_threshold_list, parameters, **kwargs):
|
||||
if isinstance(warn_thresh, str):
|
||||
warn_thresh = parameters.get('THRESHOLDS').get(warn_thresh)
|
||||
if type(warn_thresh in (float, int)):
|
||||
ax.axhline(warn_thresh, **kwargs)
|
||||
ax.axhline(warn_thresh, **kwargs)
|
@ -40,11 +40,11 @@ def get_mail_html_header():
|
||||
|
||||
|
||||
def init_html_table():
|
||||
return '<table style="width:100%">\n'
|
||||
return '<div id="managerTable" ><table style="width:100%">\n'
|
||||
|
||||
|
||||
def finish_html_table():
|
||||
return '</table>\n'
|
||||
return '</table></div>\n'
|
||||
|
||||
|
||||
def html_footer(footer_logo=None):
|
||||
@ -79,9 +79,11 @@ def get_html_row(items, html_key='td'):
|
||||
if item.get('italic'):
|
||||
text = '<i>' + text + '</i>'
|
||||
tooltip = item.get('tooltip')
|
||||
color = item.get('color')
|
||||
# check for black background of headers (shouldnt happen anymore)
|
||||
color = '#e6e6e6' if color == '#000000' else color
|
||||
font_color = item.get('font_color')
|
||||
hyperlink = item.get('hyperlink')
|
||||
color = 'transparent' if hyperlink else item.get('color')
|
||||
text_str = get_html_link(text, hyperlink) if hyperlink else text
|
||||
html_class = item.get('html_class')
|
||||
class_str = f' class="{html_class}"' if html_class else ''
|
||||
|
Loading…
x
Reference in New Issue
Block a user