[minor] only send mail on inactive when no FAIL state is present

This commit is contained in:
Marcel Paffrath 2023-02-28 11:25:43 +01:00
parent 477727018f
commit 5a4733b031

View File

@ -829,14 +829,24 @@ class StationQC(object):
return max(endtimes) return max(endtimes)
def check_for_inactive_message(self, key, dt_active): def check_for_inactive_message(self, key, dt_active):
""" send mail if station is inactive longer than dt_action and no FAIL status is present """
# check if any error is present in status_dict (in that case an email is sent already)
if self.check_for_any_error():
return
dt_action = self.get_dt_for_action() dt_action = self.get_dt_for_action()
interval = self.parameters.get('interval') interval = self.parameters.get('interval')
if dt_action <= dt_active < dt_action + timedelta(seconds=interval): if dt_action <= dt_active < dt_action + timedelta(seconds=interval):
detailed_message = f'\n{self.nwst_id}\n\n' detailed_message = f'\n{self.nwst_id}\n\n'
for key, status in self.status_dict.items(): for key, status in self.status_dict.items():
detailed_message += f'{key}: {status.message}\n' detailed_message += f'{key}: {status.message}\n'
self.send_mail(key, status_type='Inactive', additional_message=detailed_message) self.send_mail(key, status_type='Inactive', additional_message=detailed_message)
def check_for_any_error(self):
return any([status.is_error for status in self.status_dict.values()])
def start(self): def start(self):
self.analyse_channels() self.analyse_channels()