Compare commits
9 Commits
fcba73fcc5
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| f1d25a7809 | |||
| a905386ee8 | |||
| a64aeaa5ac | |||
| 206af05f26 | |||
| 0ee3a27733 | |||
| e2df92e6b4 | |||
| 8fa96d03d5 | |||
| 4e25190fbc | |||
| 8ac501e8dc |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -213,3 +213,7 @@ flycheck_*.el
|
|||||||
|
|
||||||
/__simulate_fail.json
|
/__simulate_fail.json
|
||||||
/mailing_list.yaml
|
/mailing_list.yaml
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
*.code-workspace
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ logging_level: WARN # set logging level (info, warning, debug)
|
|||||||
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: 5 # minimum samples for raising Warn/FAIL
|
min_sample: 5 # minimum samples for raising Warn/FAIL
|
||||||
dt_thresh: [300, 1800] # threshold (s) for timing delay colorization (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)
|
||||||
|
|
||||||
@@ -117,6 +117,11 @@ data_channels: ["HHZ", "HHN", "HHE"]
|
|||||||
|
|
||||||
|
|
||||||
# ---------------------------------------- OPTIONAL PARAMETERS ---------------------------------------------------------
|
# ---------------------------------------- OPTIONAL PARAMETERS ---------------------------------------------------------
|
||||||
|
# deactivate powbox surveillance for stations (e.g. for solar powered), key: station, value: status message (abbr.)
|
||||||
|
no_pbox_stations: {'GR33': 'SOL', 'GR27B': 'DCN', 'RP01': 'noPBox', 'RP02': 'noPBox', 'RP03': 'noPBox', 'RP04': 'noPBox', 'RP05B': 'noPBox', 'RP06': 'noPBox', 'RP07': 'noPBox', 'RP08': 'noPBox'}
|
||||||
|
|
||||||
|
# deactivate mass position surveillance for stations without connected mass channels (e.g. STS-2 instruments), key: station, value: status message (abbr.)
|
||||||
|
no_mass_stations: {'BIA': 'DCN', 'KNEZ': 'DCN', 'KRUS': 'DCN', 'OHR': 'DCN', 'OTOV': 'DCN', 'SKO': 'DCN', 'STIP': 'DCN', 'VAY': 'DCN', 'ZUPA': 'DCN'}
|
||||||
|
|
||||||
# add links to html table with specified key as column and value as relative link, interpretable string parameters:
|
# add links to html table with specified key as column and value as relative link, interpretable string parameters:
|
||||||
# nw (e.g. 1Y), st (e.g. GR01A), nwst_id (e.g. 1Y.GR01A)
|
# nw (e.g. 1Y), st (e.g. GR01A), nwst_id (e.g. 1Y.GR01A)
|
||||||
@@ -130,7 +135,7 @@ add_links:
|
|||||||
add_global_links:
|
add_global_links:
|
||||||
# for example: - {"text": "our homepage", "URL": "https://www.rub.de"}
|
# for example: - {"text": "our homepage", "URL": "https://www.rub.de"}
|
||||||
- {"text": "show recent events on map",
|
- {"text": "show recent events on map",
|
||||||
"URL": "https://fdsnws.geophysik.ruhr-uni-bochum.de/map/?lat=39.5&lon=21&zoom=7&baselayer=mapnik"}
|
"URL": "https://fdsnws.geophysik.ruhr-uni-bochum.de/map/?lat=39.5&lon=21&zoom=7&baselayer=osm"}
|
||||||
|
|
||||||
# html logo at page bottom (path relative to html directory)
|
# html logo at page bottom (path relative to html directory)
|
||||||
html_logo: "logo.png"
|
html_logo: "logo.png"
|
||||||
@@ -140,14 +145,14 @@ EMAIL:
|
|||||||
# specify mail server and credentials
|
# specify mail server and credentials
|
||||||
# port, auth_type, user and password are only required if mailserver is not set to "localhost"
|
# port, auth_type, user and password are only required if mailserver is not set to "localhost"
|
||||||
# user and password can be set to "ENV" or "DOCKER" to read from environment variables or docker secrets
|
# user and password can be set to "ENV" or "DOCKER" to read from environment variables or docker secrets
|
||||||
mailserver: "smtp.rub.de" # mail server
|
mailserver: "smtp.example.org" # mail server
|
||||||
auth_type: "SSL" # mail authentication type, can be "SSL", "TLS" or "None"
|
auth_type: "SSL" # mail authentication type, can be "SSL", "TLS" or "None"
|
||||||
port: 465 # mail port, default 465 for SSL, 587 for TLS
|
port: 465 # mail port, default 465 for SSL, 587 for TLS
|
||||||
user: "DOCKER" # mail user, read from environment variable if set to "ENV" or from docker secret if set to "DOCKER"
|
user: "DOCKER" # mail user, read from environment variable if set to "ENV" or from docker secret if set to "DOCKER"
|
||||||
password: "DOCKER" # mail password, read from environment variable if set to "ENV" or from docker secret if set to "DOCKER"
|
password: "DOCKER" # mail password, read from environment variable if set to "ENV" or from docker secret if set to "DOCKER"
|
||||||
# specify mail recipients, sender and blacklists
|
# specify mail recipients, sender and blacklists
|
||||||
addresses: ["marcel.paffrath@rub.de", "kasper.fischer@rub.de"] # list of mail addresses for info mails
|
addresses: ["test@example.org"] # list of mail addresses for info mails
|
||||||
sender: "RUB SeisObs <seisobs@ruhr-uni-bochum.de>" # mail sender
|
sender: "<test@example.org>" # mail sender
|
||||||
stations_blacklist: [] # do not send emails for specific stations
|
stations_blacklist: [] # do not send emails for specific stations
|
||||||
networks_blacklist: [] # do not send emails for specific network
|
networks_blacklist: [] # do not send emails for specific network
|
||||||
# specify recipients for single stations in a yaml: key = email-address, val = station list (e.g. [1Y.GR01, 1Y.GR02])
|
# specify recipients for single stations in a yaml: key = email-address, val = station list (e.g. [1Y.GR01, 1Y.GR02])
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ th {
|
|||||||
background-color: #17365c;
|
background-color: #17365c;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
padding: 10px, 2px;
|
padding: 10px 2px;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
23
survBot.py
23
survBot.py
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__version__ = '0.2-docker'
|
__version__ = '0.3.1'
|
||||||
__author__ = 'Marcel Paffrath <marcel.paffrath@rub.de>'
|
__author__ = ['Marcel Paffrath <marcel.paffrath@rub.de>', 'Kasper D. Fischer <kasper.fischer@rub.de>']
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
@@ -537,11 +537,13 @@ class SurveillanceBot(object):
|
|||||||
|
|
||||||
# write footer with optional logo
|
# write footer with optional logo
|
||||||
logo_file = self.parameters.get('html_logo')
|
logo_file = self.parameters.get('html_logo')
|
||||||
|
logo_alt_text = self.parameters.get('logo_alt_text')
|
||||||
|
logo_height = self.parameters.get('logo_height')
|
||||||
if not os.path.isfile(pjoin(self.outpath_html, logo_file)):
|
if not os.path.isfile(pjoin(self.outpath_html, logo_file)):
|
||||||
logging.info(f'Specified file {logo_file} not found.')
|
logging.info(f'Specified file {logo_file} not found.')
|
||||||
logo_file = None
|
logo_file = None
|
||||||
|
|
||||||
outfile.write(html_footer(footer_logo=logo_file))
|
outfile.write(html_footer(footer_logo=logo_file, alt_text=logo_alt_text, height=logo_height))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info(f'Could not write HTML table to {fnout}:')
|
logging.info(f'Could not write HTML table to {fnout}:')
|
||||||
@@ -551,7 +553,8 @@ class SurveillanceBot(object):
|
|||||||
|
|
||||||
def update_status_message(self):
|
def update_status_message(self):
|
||||||
timespan = timedelta(seconds=int(self.parameters.get('timespan') * 24 * 3600))
|
timespan = timedelta(seconds=int(self.parameters.get('timespan') * 24 * 3600))
|
||||||
self.status_message = f'Program starttime (UTC) {self.starttime.strftime("%Y-%m-%d %H:%M:%S")} | ' \
|
self.status_message = f' Version {__version__} | ' \
|
||||||
|
f'Program start time (UTC) {self.starttime.strftime("%Y-%m-%d %H:%M:%S")} | ' \
|
||||||
f'Current time (UTC) {UTCDateTime().strftime("%Y-%m-%d %H:%M:%S")} | ' \
|
f'Current time (UTC) {UTCDateTime().strftime("%Y-%m-%d %H:%M:%S")} | ' \
|
||||||
f'Refresh period: {self.refresh_period}s | ' \
|
f'Refresh period: {self.refresh_period}s | ' \
|
||||||
f'Showing data of last {timespan}'
|
f'Showing data of last {timespan}'
|
||||||
@@ -595,6 +598,7 @@ class StationQC(object):
|
|||||||
self.status_track = status_track
|
self.status_track = status_track
|
||||||
|
|
||||||
self.powbox_active = self.is_pbox_activated_check()
|
self.powbox_active = self.is_pbox_activated_check()
|
||||||
|
self.mass_active = self.is_mass_activated_check()
|
||||||
|
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
@@ -1080,6 +1084,11 @@ class StationQC(object):
|
|||||||
""" Analyse datalogger mass channels. """
|
""" Analyse datalogger mass channels. """
|
||||||
key = 'mass'
|
key = 'mass'
|
||||||
|
|
||||||
|
# skip processing if mass is not active
|
||||||
|
if not self.mass_active:
|
||||||
|
self.set_mass_inactive_error(key)
|
||||||
|
return
|
||||||
|
|
||||||
# build stream with all channels
|
# build stream with all channels
|
||||||
st = Stream()
|
st = Stream()
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
@@ -1341,6 +1350,12 @@ class StationQC(object):
|
|||||||
msg = self.parameters.get('no_pbox_stations')[self.station]
|
msg = self.parameters.get('no_pbox_stations')[self.station]
|
||||||
self.error(key, detailed_message=f'PowBox not connected', disc=msg)
|
self.error(key, detailed_message=f'PowBox not connected', disc=msg)
|
||||||
|
|
||||||
|
def is_mass_activated_check(self):
|
||||||
|
return self.station not in self.parameters.get('no_mass_stations', [])
|
||||||
|
|
||||||
|
def set_mass_inactive_error(self, key):
|
||||||
|
msg = self.parameters.get('no_mass_stations')[self.station]
|
||||||
|
self.error(key, detailed_message=f'Mass channels not connected', disc=msg)
|
||||||
|
|
||||||
class Status(object):
|
class Status(object):
|
||||||
""" Basic Status class. All status classes are derived from this class."""
|
""" Basic Status class. All status classes are derived from this class."""
|
||||||
|
|||||||
@@ -17,15 +17,16 @@ def get_html_text(text):
|
|||||||
|
|
||||||
def get_html_header(refresh_rate=10):
|
def get_html_header(refresh_rate=10):
|
||||||
header = ['<!DOCTYPE html>',
|
header = ['<!DOCTYPE html>',
|
||||||
'<html>',
|
'<html lang="en">',
|
||||||
'<head>',
|
'<head>',
|
||||||
' <link rel="stylesheet" media="only screen and (max-width: 400px)" href="mobile.css" />',
|
' <title>SurvBot status</title>',
|
||||||
' <link rel="stylesheet" media="only screen and (min-width: 401px)" href="desktop.css" />',
|
' <link rel="stylesheet" media="only screen and (max-width: 400px)" href="mobile.css">',
|
||||||
|
' <link rel="stylesheet" media="only screen and (min-width: 401px)" href="desktop.css">',
|
||||||
|
f' <meta http-equiv="refresh" content="{refresh_rate}">',
|
||||||
|
' <meta charset="utf-8">',
|
||||||
|
' <meta name="viewport" content="width=device-width, initial-scale=1">',
|
||||||
'</head>',
|
'</head>',
|
||||||
f'<meta http-equiv="refresh" content="{refresh_rate}" >',
|
'<body>\n']
|
||||||
'<meta charset="utf-8">',
|
|
||||||
'<meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
||||||
'<body>']
|
|
||||||
header = _convert_to_textstring(header)
|
header = _convert_to_textstring(header)
|
||||||
return header
|
return header
|
||||||
|
|
||||||
@@ -47,14 +48,15 @@ def finish_html_table():
|
|||||||
return '</table>\n'
|
return '</table>\n'
|
||||||
|
|
||||||
|
|
||||||
def html_footer(footer_logo=None):
|
def html_footer(footer_logo=None, alt_text='Logo', height=30):
|
||||||
footer = ['</body>']
|
|
||||||
if footer_logo:
|
if footer_logo:
|
||||||
logo_items = [f'<div class="footer">',
|
footer = [f'<div class="footer">',
|
||||||
f' <img style="float: right; padding: 10px;" src="{footer_logo}" height=30px>',
|
f' <img style="float: right; padding: 10px;" src="{footer_logo}" height={height} alt="{alt_text}">',
|
||||||
f'</div>']
|
f'</div>']
|
||||||
footer += logo_items
|
else:
|
||||||
footer.append('</html>\n')
|
footer = []
|
||||||
|
footer.append('</body>')
|
||||||
|
footer.append('</html>')
|
||||||
|
|
||||||
footer = _convert_to_textstring(footer)
|
footer = _convert_to_textstring(footer)
|
||||||
return footer
|
return footer
|
||||||
@@ -85,8 +87,14 @@ def get_html_row(items, html_key='td'):
|
|||||||
text_str = get_html_link(text, hyperlink) 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}"' \
|
row_string += 2 * default_space + f'<{html_key}{class_str} '
|
||||||
+ f'style="color:{font_color}"> {text_str}</{html_key}>\n'
|
row_string += f'title="{tooltip}" ' if tooltip else ''
|
||||||
|
row_string += 'style="' if color or font_color else ''
|
||||||
|
row_string += f'background-color: {color};' if color else 'style="'
|
||||||
|
row_string += ' ' if font_color else ''
|
||||||
|
row_string += f'color: {font_color};' if font_color else ''
|
||||||
|
row_string += '" ' if color or font_color else ''
|
||||||
|
row_string += f'>{text_str}</{html_key}>\n'
|
||||||
row_string += default_space + '</tr>\n'
|
row_string += default_space + '</tr>\n'
|
||||||
return row_string
|
return row_string
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user