More customizable Blocking

Start work to add function-specific blocking in addition to global blocking
pull/1/head
Mason10198 3 years ago
parent 40f2ee15c5
commit eb80a7ea43

@ -55,7 +55,9 @@ if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir) os.makedirs(tmp_dir)
# List of blocked events # List of blocked events
blocked_events = config["Blocking"].get("BlockedEvents").split(",") global_blocked_events = config["Blocking"].get("GlobalBlockedEvents").split(",")
sayalert_blocked_events = config["Blocking"].get("SayAlertBlockedEvents").split(",")
tailmessage_blocked_events = config["Blocking"].get("TailmessageBlockedEvents").split(",")
# Configuration for tailmessage # Configuration for tailmessage
tailmessage_config = config["Tailmessage"] tailmessage_config = config["Tailmessage"]
# Flag to enable/disable tailmessage # Flag to enable/disable tailmessage
@ -252,7 +254,7 @@ logger.debug("Base directory: {}".format(baseDir))
logger.debug("Temporary directory: {}".format(tmp_dir)) logger.debug("Temporary directory: {}".format(tmp_dir))
logger.debug("Sounds path: {}".format(sounds_path)) logger.debug("Sounds path: {}".format(sounds_path))
logger.debug("Tailmessage path: {}".format(tailmessage_file)) logger.debug("Tailmessage path: {}".format(tailmessage_file))
logger.debug("Blocked events: {}".format(blocked_events)) logger.debug("Global Blocked events: {}".format(global_blocked_events))
def getAlerts(countyCodes): def getAlerts(countyCodes):
@ -292,10 +294,10 @@ def getAlerts(countyCodes):
expires_time = parser.isoparse(expires) expires_time = parser.isoparse(expires)
if expires_time > current_time: if expires_time > current_time:
event = feature["properties"]["event"] event = feature["properties"]["event"]
for blocked_event in blocked_events: for global_blocked_event in global_blocked_events:
if fnmatch.fnmatch(event, blocked_event): if fnmatch.fnmatch(event, global_blocked_event):
logger.debug( logger.debug(
"Blocking {} as per configuration".format(event) "Globally Blocking {} as per configuration".format(event)
) )
break break
else: else:
@ -329,6 +331,11 @@ def sayAlert(alerts):
) )
for alert in alerts: for alert in alerts:
# Check if alert is in the SayAlertBlockedEvents list
if alert in sayalert_blocked_events:
logger.debug("Alert blocked by SayAlertBlockedEvents: {}".format(alert))
continue
try: try:
index = WS.index(alert) index = WS.index(alert)
audio_file = AudioSegment.from_wav( audio_file = AudioSegment.from_wav(

@ -35,8 +35,19 @@ SayAllClear = True
; Blocking settings ; Blocking settings
[Blocking] [Blocking]
; GLOBAL BLOCKING - These alerts will be completely ignored and filtered out of the entire SkywarnPlus workflow
; CASE SENSITIVE list of events to ignore, comma separated. Wildcards can be used, e.g. *Statement, *Advisory ; CASE SENSITIVE list of events to ignore, comma separated. Wildcards can be used, e.g. *Statement, *Advisory
BlockedEvents = GlobalBlockedEvents =
; SayAlert Blocking
; These alerts will be blocked from being spoken when they are received
; These alerts will still be added to the tailmessage
SayAlertBlockedEvents =
; Tailmessage Blocking
; These alerts will be blocked from being added to the tailmessage
; These alerts will still be spoken when they are received
TailmessageBlockedEvents =
; Tail message settings ; Tail message settings
[Tailmessage] [Tailmessage]

Loading…
Cancel
Save

Powered by TurnKey Linux.