From a6c792b27170745b91a81173feeb03ccec034d05 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 16 Feb 2023 15:49:07 +0100 Subject: [PATCH] [bugfix] some bugfixes/tweaks --- parameters.yaml | 4 ++-- simulate_fail.json | 2 -- survBot.py | 7 +++++-- utils.py | 9 +++++---- write_utils.py | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 simulate_fail.json diff --git a/parameters.yaml b/parameters.yaml index 4d12005..4bc4d72 100644 --- a/parameters.yaml +++ b/parameters.yaml @@ -7,7 +7,7 @@ stations_blacklist: ["TEST", "EREA"] # 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) -timespan: 1 # Check data of the recent x days +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 @@ -125,7 +125,7 @@ add_links: # E-mail notifications EMAIL: mailserver: "localhost" - addresses: ["marcel.paffrath@rub.de",]# "kasper.fischer@rub.de"] # list of mail addresses for info mails + addresses: ["marcel.paffrath@rub.de", "kasper.fischer@rub.de"] # list of mail addresses for info mails sender: "webmaster@geophysik.ruhr-uni-bochum.de" # mail sender stations_blacklist: ['GR33'] # do not send emails for specific stations networks_blacklist: [] # do not send emails for specific network diff --git a/simulate_fail.json b/simulate_fail.json deleted file mode 100644 index 33bd01e..0000000 --- a/simulate_fail.json +++ /dev/null @@ -1,2 +0,0 @@ -{"1Y.GR01": "230V", -"1Y.GR03": "charger"} \ No newline at end of file diff --git a/survBot.py b/survBot.py index 9cd5be1..44c2a8b 100755 --- a/survBot.py +++ b/survBot.py @@ -69,7 +69,7 @@ def get_nwst_id(trace): def fancy_timestr(dt, thresh=600, modif='+'): - if dt > timedelta(seconds=thresh): + if isinstance(dt, timedelta) and dt > timedelta(seconds=thresh): value = f'{modif} ' + str(dt) + f' {modif}' else: value = str(dt) @@ -643,7 +643,7 @@ class StationQC(object): if n_errors is None: n_errors = self.parameters.get('n_track') - # +1 to check whether n_errors +1 was no error (error is new) + # +1 to check whether n_errors + 1 was no error (error is new) n_errors += 1 # simulate an error specified in json file (dictionary: {nwst_id: key} ) @@ -657,6 +657,9 @@ class StationQC(object): # if first entry was no error but all others are, return True (-> new Fail n_track times) if not previous_errors[0] and all(previous_errors[1:]): return True + # special case: n_errors set to 1 (+1) to check for upcoming error (refresh plot etc.), but not on startup + if not previous_errors[0] and n_errors == 2: + return True # in case previous_errors exists, last item is error but not all items are error, error still active elif previous_errors and previous_errors[-1] and not all(previous_errors): return 'active' diff --git a/utils.py b/utils.py index f433d9c..cacbb5d 100644 --- a/utils.py +++ b/utils.py @@ -47,10 +47,11 @@ def get_color_mpl(key): def get_time_delay_color(dt, dt_thresh): """ Set color of time delay after thresholds specified in self.dt_thresh """ - if dt < dt_thresh[0]: - return get_color('OK') - elif dt_thresh[0] <= dt < dt_thresh[1]: - return get_color('WARN') + if isinstance(dt, type(dt_thresh[0])): + if dt < dt_thresh[0]: + return get_color('OK') + elif dt_thresh[0] <= dt < dt_thresh[1]: + return get_color('WARN') return get_color('FAIL') diff --git a/write_utils.py b/write_utils.py index c1ae268..d571c2a 100644 --- a/write_utils.py +++ b/write_utils.py @@ -55,7 +55,7 @@ def html_footer(): def add_html_image(img_data, img_format='png'): - return f"""
\n""" + return f"""
\n""" def get_html_row(items, html_key='td'):