[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
|
# Parameters file for Surveillance Bot
|
||||||
datapath: "/data/SDS/" # SC3 Datapath
|
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
|
stations: "*" # select stations, list or str
|
||||||
locations: "*" # select locations, 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
|
networks_blacklist: [] # exclude these networks
|
||||||
interval: 60 # Perform checks every x seconds
|
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
|
timespan: 3 # Check data of the recent x days
|
||||||
verbosity: 0 # verbosity flag
|
verbosity: 0 # verbosity flag
|
||||||
track_changes: True # tracks all changes since GUI startup by text highlighting (GUI only)
|
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
|
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)
|
dt_thresh: [300, 1800] # threshold (s) for timing delay colourisation (yellow/red)
|
||||||
html_figures: True # Create html figure directory and links
|
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)
|
reread_parameters: True # reread parameters file (change parameters on runtime, not for itself/GUI refresh/datapath)
|
||||||
@ -72,12 +72,12 @@ CHANNELS:
|
|||||||
EX2:
|
EX2:
|
||||||
unit: 1e-6
|
unit: 1e-6
|
||||||
name: "PowBox 230V/12V (V)"
|
name: "PowBox 230V/12V (V)"
|
||||||
ticks: [1, 5, 1]
|
ticks: [0, 5, 1]
|
||||||
warn: [2, 3, 4, 4.5, 5]
|
warn: [2, 3, 4, 4.5, 5]
|
||||||
EX3:
|
EX3:
|
||||||
unit: 1e-6
|
unit: 1e-6
|
||||||
name: "PowBox Router/Charger (V)"
|
name: "PowBox Router/Charger (V)"
|
||||||
ticks: [1, 5, 1]
|
ticks: [0, 5, 1]
|
||||||
warn: [2, 2.5, 3, 4, 5]
|
warn: [2, 2.5, 3, 4, 5]
|
||||||
VEI:
|
VEI:
|
||||||
unit: 1e-3
|
unit: 1e-3
|
||||||
@ -122,6 +122,12 @@ add_links:
|
|||||||
slmon: {"URL": "../slmon/{nw}_{st}.html", "text": "show"}
|
slmon: {"URL": "../slmon/{nw}_{st}.html", "text": "show"}
|
||||||
24h-plot: {"URL": "../scheli/{nw}/{st}.png", "text": "plot"}
|
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
|
# E-mail notifications
|
||||||
EMAIL:
|
EMAIL:
|
||||||
mailserver: "localhost"
|
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 import read, UTCDateTime, Stream
|
||||||
from obspy.clients.filesystem.sds import Client
|
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
|
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
|
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.networks_blacklist = self.parameters.get('networks_blacklist')
|
||||||
self.refresh_period = self.parameters.get('interval')
|
self.refresh_period = self.parameters.get('interval')
|
||||||
self.transform_parameters()
|
self.transform_parameters()
|
||||||
|
|
||||||
add_links = self.parameters.get('add_links')
|
add_links = self.parameters.get('add_links')
|
||||||
self.add_links = add_links if add_links else {}
|
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):
|
def transform_parameters(self):
|
||||||
for key in ['networks', 'stations', 'locations', 'channels']:
|
for key in ['networks', 'stations', 'locations', 'channels']:
|
||||||
parameter = self.parameters.get(key)
|
parameter = self.parameters.get(key)
|
||||||
@ -496,6 +503,10 @@ class SurveillanceBot(object):
|
|||||||
|
|
||||||
outfile.write(finish_html_table())
|
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(get_html_text(self.status_message))
|
||||||
outfile.write(html_footer())
|
outfile.write(html_footer())
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ def finish_html_table():
|
|||||||
|
|
||||||
def html_footer():
|
def html_footer():
|
||||||
footer = ['</body>',
|
footer = ['</body>',
|
||||||
'</html>']
|
'</html>\n']
|
||||||
footer = _convert_to_textstring(footer)
|
footer = _convert_to_textstring(footer)
|
||||||
return 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')}">"""
|
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'):
|
def get_html_row(items, html_key='td'):
|
||||||
row_string = ''
|
row_string = ''
|
||||||
default_space = ' '
|
default_space = ' '
|
||||||
@ -73,7 +77,7 @@ def get_html_row(items, html_key='td'):
|
|||||||
# check for black background of headers (shouldnt happen anymore)
|
# check for black background of headers (shouldnt happen anymore)
|
||||||
color = '#e6e6e6' if color == '#000000' else color
|
color = '#e6e6e6' if color == '#000000' else color
|
||||||
hyperlink = item.get('hyperlink')
|
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')
|
html_class = item.get('html_class')
|
||||||
class_str = f' class="{html_class}"' if html_class else ''
|
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}'\
|
row_string += 2 * default_space + f'<{html_key}{class_str} bgcolor="{color}" title="{tooltip}"> {text_str}'\
|
||||||
|
Loading…
Reference in New Issue
Block a user