[update] can add global (station-independent) links on html web page
This commit is contained in:
parent
1b010ecb61
commit
acc8575d70
@ -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,12 @@ 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"}
|
||||
|
||||
# E-mail notifications
|
||||
EMAIL:
|
||||
mailserver: "localhost"
|
||||
|
13
survBot.py
13
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,6 +503,10 @@ 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())
|
||||
|
||||
|
@ -49,7 +49,7 @@ def finish_html_table():
|
||||
|
||||
def html_footer():
|
||||
footer = ['</body>',
|
||||
'</html>']
|
||||
'</html>\n']
|
||||
footer = _convert_to_textstring(footer)
|
||||
return footer
|
||||
|
||||
@ -58,6 +58,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,7 +77,7 @@ 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')
|
||||
text_str = f'<a href="{hyperlink}"> {text} </a>' if hyperlink else text
|
||||
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}"> {text_str}'\
|
||||
|
Loading…
Reference in New Issue
Block a user