[update] html output from GUI in background possible but maybe not optimal (needs display to work in bg)
This commit is contained in:
parent
37b73d4393
commit
68c6df72c9
@ -1,6 +1,5 @@
|
||||
# Parameters file for Surveillance Bot
|
||||
datapath: '/data/SDS/' # SC3 Datapath
|
||||
outpath_html: '/home/marcel/tmp/survBot_out.html' # output of HTML table
|
||||
networks: ['1Y', 'HA']
|
||||
stations: '*'
|
||||
locations: '*'
|
||||
|
@ -2,15 +2,20 @@
|
||||
ulimit -s 8192
|
||||
|
||||
#$ -l low
|
||||
#$ -l os=*stretch
|
||||
#$ -l h_vmem=5G
|
||||
#$ -cwd
|
||||
#$ -pe smp 1
|
||||
##$ -q "*@minos15"
|
||||
#$ -N survBot_bg
|
||||
|
||||
export PYTHONPATH="$PYTHONPATH:/home/marcel/git/"
|
||||
export PYTHONPATH="$PYTHONPATH:/home/marcel/git/code_base/"
|
||||
|
||||
source /opt/anaconda3/etc/profile.d/conda.sh
|
||||
conda activate py37
|
||||
|
||||
python survBot.py
|
||||
# environment variables for numpy to prevent multi threading
|
||||
export MKL_NUM_THREADS=1
|
||||
export NUMEXPR_NUM_THREADS=1
|
||||
export OMP_NUM_THREADS=1
|
||||
|
||||
|
||||
python survBotGUI.py -html '/home/marcel/public_html/survBot_out.html' --background
|
||||
|
@ -1,4 +1,5 @@
|
||||
#! /usr/bin/env python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__version__ = '0.1'
|
||||
__author__ = 'Marcel Paffrath'
|
||||
@ -510,7 +511,7 @@ class StationQC(object):
|
||||
self.warn(key=key,
|
||||
message=f'Trace {trace.get_id()}: '
|
||||
f'Voltage below {pb_ok}V {len(under)} times. '
|
||||
f'Mean voltage: {np.mean(voltage)}'
|
||||
f'Mean voltage: {np.mean(voltage):.2}'
|
||||
+ self.get_last_occurrence_timestring(trace, under),
|
||||
status_message='WARN ({})'.format(n_occurrences))
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#! /usr/bin/env python
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
GUI overlay for the main survBot to show quality control of different stations specified in parameters.yaml file.
|
||||
"""
|
||||
@ -77,7 +78,7 @@ class Thread(QtCore.QThread):
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
def __init__(self, parameters='parameters.yaml', dt_thresh=(300, 1800)):
|
||||
def __init__(self, parameters='parameters.yaml', outpath_html=None, dt_thresh=(300, 1800)):
|
||||
"""
|
||||
Main window of survBot GUI.
|
||||
:param parameters: Parameters dictionary file (yaml format)
|
||||
@ -98,6 +99,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.last_mouse_loc = None
|
||||
self.status_message = ''
|
||||
self.starttime = UTCDateTime()
|
||||
self.outpath_html = outpath_html
|
||||
|
||||
# setup main layout of the GUI
|
||||
self.main_layout = QtWidgets.QVBoxLayout()
|
||||
@ -184,12 +186,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
return super(QtWidgets.QMainWindow, self).eventFilter(object, event)
|
||||
|
||||
def write_html_table(self):
|
||||
fnout = self.parameters.get('outpath_html')
|
||||
fnout = self.outpath_html
|
||||
if not fnout:
|
||||
return
|
||||
try:
|
||||
with open(fnout, 'w') as outfile:
|
||||
write_html_header(outfile)
|
||||
write_html_header(outfile, self.refresh_period)
|
||||
#write_html_table_title(outfile, self.parameters)
|
||||
init_html_table(outfile)
|
||||
nrows = self.table.rowCount()
|
||||
@ -272,6 +274,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
def fill_table(self):
|
||||
""" Fills the table with most recent information. Executed after execute_qc thread is done or on refresh. """
|
||||
|
||||
# fill status bar first with new time
|
||||
self.fill_status_bar()
|
||||
|
||||
for col_ind, check_key in enumerate(self.survBot.keys):
|
||||
for row_ind, st_id in enumerate(self.survBot.station_list):
|
||||
status_dict, detailed_dict = self.survBot.analysis_results.get(st_id)
|
||||
@ -501,9 +507,15 @@ class SendSMSWidget(QtWidgets.QDialog):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Call survBot GUI')
|
||||
parser.add_argument('-html', dest='html_filename', default=None, help='filename for HTML output')
|
||||
parser.add_argument('--background', dest='background', default=False, action='store_true', help='run in background')
|
||||
args = parser.parse_args()
|
||||
|
||||
program_path = sys.path[0]
|
||||
parameters = os.path.join(program_path, 'parameters.yaml')
|
||||
app = QtWidgets.QApplication([])
|
||||
window = MainWindow(parameters=parameters)
|
||||
window.showMaximized()
|
||||
window = MainWindow(parameters=parameters, outpath_html=args.html_filename)
|
||||
if not args.background:
|
||||
window.showMaximized()
|
||||
sys.exit(app.exec_())
|
||||
|
@ -7,15 +7,17 @@ def write_html_table_title(fobj, parameters):
|
||||
def write_html_text(fobj, text):
|
||||
fobj.write(f'<p>{text}</p>\n')
|
||||
|
||||
def write_html_header(fobj):
|
||||
def write_html_header(fobj, refresh_rate=10):
|
||||
header = ['<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<style>',
|
||||
'table, th, td {',
|
||||
'border:1px solid black;',
|
||||
'}',
|
||||
'</style>',
|
||||
f'<meta http-equiv="refresh" content="{refresh_rate}" >',
|
||||
'<meta charset="utf-8">',
|
||||
'<body>']
|
||||
# style = ['<style>',
|
||||
# 'table, th, td {',
|
||||
# 'border:1px solid black;',
|
||||
# '}',
|
||||
# '</style>',]
|
||||
for item in header:
|
||||
fobj.write(item + '\n')
|
||||
|
||||
@ -32,14 +34,16 @@ def write_html_footer(fobj):
|
||||
fobj.write(item + '\n')
|
||||
|
||||
def write_html_row(fobj, items, html_key='td'):
|
||||
fobj.write('<tr>\n')
|
||||
default_space = ' '
|
||||
fobj.write(default_space + '<tr>\n')
|
||||
for item in items:
|
||||
text = item.text()
|
||||
tooltip = item.toolTip()
|
||||
color = item.backgroundColor().name()
|
||||
# fix for black background of headers
|
||||
color = '#e6e6e6' if color == '#000000' else color
|
||||
fobj.write(f'<{html_key} bgcolor="{color}">' + text + f'</{html_key}>\n')
|
||||
fobj.write('</tr>\n')
|
||||
fobj.write(2 * default_space + f'<{html_key} bgcolor="{color}" title="{tooltip}">' + text + f'</{html_key}>\n')
|
||||
fobj.write(default_space + '</tr>\n')
|
||||
|
||||
def get_print_title_str(parameters):
|
||||
timespan = parameters.get('timespan') * 24 * 3600
|
||||
|
Loading…
Reference in New Issue
Block a user