Compare commits
4 Commits
174a6148bf
...
fb4d5c2929
Author | SHA1 | Date | |
---|---|---|---|
fb4d5c2929 | |||
1983cc3b1e | |||
acc8575d70 | |||
1b010ecb61 |
@ -1,17 +1,17 @@
|
||||
# Parameters file for Surveillance Bot
|
||||
datapath: "/data/SDS/" # SC3 Datapath
|
||||
networks: ["1Y", "HA"] # select networks, list or str
|
||||
networks: ["1Y", "HA", "MK"] # select networks, list or str
|
||||
stations: "*" # select stations, list or str
|
||||
locations: "*" # select locations, list or str
|
||||
stations_blacklist: ["TEST", "EREA"] # exclude these stations
|
||||
stations_blacklist: ["TEST", "EREA", "DOMV"] # exclude these stations
|
||||
networks_blacklist: [] # exclude these networks
|
||||
interval: 60 # Perform checks every x seconds
|
||||
n_track: 300 # wait n_track * intervals before performing an action (i.e. send mail/end highlight status)
|
||||
n_track: 360 # wait n_track * intervals before performing an action (i.e. send mail/end highlight status)
|
||||
timespan: 3 # Check data of the recent x days
|
||||
verbosity: 0 # verbosity flag
|
||||
track_changes: True # tracks all changes since GUI startup by text highlighting (GUI only)
|
||||
warn_count: False # show number of warnings and errors in table
|
||||
min_sample: 3 # minimum samples for raising Warn/FAIL
|
||||
min_sample: 5 # minimum samples for raising Warn/FAIL
|
||||
dt_thresh: [300, 1800] # threshold (s) for timing delay colourisation (yellow/red)
|
||||
html_figures: True # Create html figure directory and links
|
||||
reread_parameters: True # reread parameters file (change parameters on runtime, not for itself/GUI refresh/datapath)
|
||||
@ -72,12 +72,12 @@ CHANNELS:
|
||||
EX2:
|
||||
unit: 1e-6
|
||||
name: "PowBox 230V/12V (V)"
|
||||
ticks: [1, 5, 1]
|
||||
ticks: [0, 5, 1]
|
||||
warn: [2, 3, 4, 4.5, 5]
|
||||
EX3:
|
||||
unit: 1e-6
|
||||
name: "PowBox Router/Charger (V)"
|
||||
ticks: [1, 5, 1]
|
||||
ticks: [0, 5, 1]
|
||||
warn: [2, 2.5, 3, 4, 5]
|
||||
VEI:
|
||||
unit: 1e-3
|
||||
@ -122,6 +122,15 @@ add_links:
|
||||
slmon: {"URL": "../slmon/{nw}_{st}.html", "text": "show"}
|
||||
24h-plot: {"URL": "../scheli/{nw}/{st}.png", "text": "plot"}
|
||||
|
||||
# add station-independent links below html table (list items separated with -)
|
||||
add_global_links:
|
||||
# for example: - {"text": "our homepage", "URL": "https://www.rub.de"}
|
||||
- {"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
|
||||
html_logo: "figures/Logo_RUB_BLAU_rgb.png"
|
||||
|
||||
# E-mail notifications
|
||||
EMAIL:
|
||||
mailserver: "localhost"
|
||||
|
@ -2,11 +2,13 @@ body {
|
||||
background-color: #ffffff;
|
||||
place-items: center;
|
||||
text-align: center;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
td {
|
||||
border-radius: 4px;
|
||||
padding: 0px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
th {
|
||||
@ -37,3 +39,12 @@ a:hover {
|
||||
50% { background-color: #ff3200;}
|
||||
100% { background-color: #ffcc00;}
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -2,11 +2,13 @@ body {
|
||||
background-color: #ffffff;
|
||||
place-items: center;
|
||||
text-align: center;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
td {
|
||||
border-radius: 4px;
|
||||
padding: 10px 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
th {
|
||||
@ -41,3 +43,12 @@ a:hover {
|
||||
50% { background-color: #ff3200;}
|
||||
100% { background-color: #ffee00;}
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
text-align: center;
|
||||
}
|
||||
|
15
survBot.py
15
survBot.py
@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
|
||||
from obspy import read, UTCDateTime, Stream
|
||||
from obspy.clients.filesystem.sds import Client
|
||||
|
||||
from write_utils import get_html_text, get_html_row, html_footer, get_html_header, get_print_title_str, \
|
||||
from write_utils import get_html_text, get_html_link, get_html_row, html_footer, get_html_header, get_print_title_str, \
|
||||
init_html_table, finish_html_table, get_mail_html_header, add_html_image
|
||||
from utils import get_bg_color, modify_stream_for_plot, set_axis_yticks, set_axis_color, plot_axis_thresholds
|
||||
|
||||
@ -120,9 +120,16 @@ class SurveillanceBot(object):
|
||||
self.networks_blacklist = self.parameters.get('networks_blacklist')
|
||||
self.refresh_period = self.parameters.get('interval')
|
||||
self.transform_parameters()
|
||||
|
||||
add_links = self.parameters.get('add_links')
|
||||
self.add_links = add_links if add_links else {}
|
||||
|
||||
add_global_links = self.parameters.get('add_global_links')
|
||||
# in case user forgets "-" in parameters file
|
||||
if isinstance(add_global_links, dict):
|
||||
add_global_links = [add_global_links]
|
||||
self.add_global_links = add_global_links if add_global_links else []
|
||||
|
||||
def transform_parameters(self):
|
||||
for key in ['networks', 'stations', 'locations', 'channels']:
|
||||
parameter = self.parameters.get(key)
|
||||
@ -496,8 +503,12 @@ class SurveillanceBot(object):
|
||||
|
||||
outfile.write(finish_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))
|
||||
|
||||
outfile.write(get_html_text(self.status_message))
|
||||
outfile.write(html_footer())
|
||||
outfile.write(html_footer(footer_logo=self.parameters.get('html_logo')))
|
||||
|
||||
except Exception as e:
|
||||
print(f'Could not write HTML table to {fnout}:')
|
||||
|
@ -47,9 +47,15 @@ def finish_html_table():
|
||||
return '</table>\n'
|
||||
|
||||
|
||||
def html_footer():
|
||||
footer = ['</body>',
|
||||
'</html>']
|
||||
def html_footer(footer_logo=None):
|
||||
footer = ['</body>']
|
||||
if footer_logo:
|
||||
logo_items = [f'<div class="footer">',
|
||||
f' <img style="float: right; padding: 10px;" src="{footer_logo}" height=30px>',
|
||||
f'</div>']
|
||||
footer += logo_items
|
||||
footer.append('</html>\n')
|
||||
|
||||
footer = _convert_to_textstring(footer)
|
||||
return footer
|
||||
|
||||
@ -58,6 +64,10 @@ def add_html_image(img_data, img_format='png'):
|
||||
return f"""<br>\n<img width="100%" src="data:image/{img_format};base64, {b64encode(img_data).decode('ascii')}">"""
|
||||
|
||||
|
||||
def get_html_link(text, link):
|
||||
return f'<a href="{link}"> {text} </a>'
|
||||
|
||||
|
||||
def get_html_row(items, html_key='td'):
|
||||
row_string = ''
|
||||
default_space = ' '
|
||||
@ -73,11 +83,11 @@ def get_html_row(items, html_key='td'):
|
||||
# check for black background of headers (shouldnt happen anymore)
|
||||
color = '#e6e6e6' if color == '#000000' else color
|
||||
hyperlink = item.get('hyperlink')
|
||||
image_str = f'<a href="{hyperlink}">' if hyperlink else ''
|
||||
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 ''
|
||||
row_string += 2 * default_space + f'<{html_key}{class_str} bgcolor="{color}" title="{tooltip}"> {image_str}'\
|
||||
+ text + f'</{html_key}>\n'
|
||||
row_string += 2 * default_space + f'<{html_key}{class_str} bgcolor="{color}" title="{tooltip}"> {text_str}'\
|
||||
+ f'</{html_key}>\n'
|
||||
row_string += default_space + '</tr>\n'
|
||||
return row_string
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user