v0.4.3 update

pull/140/head
Mason10198 2 years ago
parent 48a4ee66e2
commit 2d45fef53c

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
""" """
SkyControl v0.4.2 by Mason Nelson SkyControl v0.4.3 by Mason Nelson
================================== ==================================
A Control Script for SkywarnPlus A Control Script for SkywarnPlus

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
""" """
SkyDescribe v0.4.2 by Mason Nelson SkyDescribe v0.4.3 by Mason Nelson
================================================== ==================================================
Text to Speech conversion for Weather Descriptions Text to Speech conversion for Weather Descriptions
@ -267,6 +267,13 @@ def convert_to_audio(api_key, text):
return audio_file_path return audio_file_path
def pluralize(word):
if word.endswith('s') or word.endswith('sh') or word.endswith('ch') or word.endswith('x'):
return word + 'es'
else:
return word + 's'
def main(index_or_title): def main(index_or_title):
state = load_state() state = load_state()
alerts = list(state["last_alerts"].items()) alerts = list(state["last_alerts"].items())
@ -296,9 +303,9 @@ def main(index_or_title):
if unique_instances == 1: if unique_instances == 1:
description = alert_data[0]["description"] description = alert_data[0]["description"]
else: else:
description = "There are {} unique instances of {}. Describing the first one. {}".format( description = "There are {} unique {} in the area. Describing the first one. {}".format(
unique_instances, unique_instances,
alert, pluralize(alert),
alert_data[0]["description"] alert_data[0]["description"]
) )
@ -319,9 +326,9 @@ def main(index_or_title):
if unique_instances == 1: if unique_instances == 1:
description = alert_data[0]["description"] description = alert_data[0]["description"]
else: else:
description = "There are {} unique instances of {}. Describing the first one. {}".format( description = "There are {} unique {} in the area. Describing the first one. {}".format(
unique_instances, unique_instances,
alert, pluralize(alert),
alert_data[0]["description"] alert_data[0]["description"]
) )
break break

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
""" """
SkywarnPlus v0.4.2 by Mason Nelson SkywarnPlus v0.4.3 by Mason Nelson
=============================================================================== ===============================================================================
SkywarnPlus is a utility that retrieves severe weather alerts from the National SkywarnPlus is a utility that retrieves severe weather alerts from the National
Weather Service and integrates these alerts with an Asterisk/app_rpt based Weather Service and integrates these alerts with an Asterisk/app_rpt based
@ -1345,6 +1345,34 @@ def supermon_back_compat(alerts):
file.write("<br>".join(alert_titles)) file.write("<br>".join(alert_titles))
def detect_new_counties(old_alerts, new_alerts):
"""
Detect if any new counties have been added to an alert.
"""
is_new_counties = False
alerts_with_new_counties = {}
for alert_name, alert_info in new_alerts.items():
old_alert_info = old_alerts.get(alert_name, [])
old_county_codes = {info['county_code'] for info in old_alert_info}
new_county_codes = {info['county_code'] for info in alert_info}
added_counties = new_county_codes - old_county_codes
old_county_codes = {code.replace("{", "").replace("}", "").replace('"', "") for code in old_county_codes}
added_counties = {code.replace("{", "").replace("}", "").replace('"', "") for code in added_counties}
if added_counties:
alerts_with_new_counties[alert_name] = new_alerts[alert_name]
LOGGER.info('{} for {} is now also affecting: {}'.format(alert_name, ", ".join(old_county_codes), ", ".join(added_counties)))
is_new_counties = True
if COUNTY_WAVS and alerts_with_new_counties:
say_alerts(alerts_with_new_counties)
if config.get("Tailmessage", {}).get("TailmessageCounties", False):
build_tailmessage(alerts_with_new_counties)
return is_new_counties
def main(): def main():
""" """
The main function that orchestrates the entire process of fetching and The main function that orchestrates the entire process of fetching and
@ -1457,13 +1485,17 @@ def main():
LOGGER.debug("Sending pushover notification: %s", pushover_message) LOGGER.debug("Sending pushover notification: %s", pushover_message)
send_pushover(pushover_message, title="Alerts Changed") send_pushover(pushover_message, title="Alerts Changed")
else: else:
if sys.stdin.isatty(): if not detect_new_counties(last_alerts, alerts):
# list of current alerts, unless there arent any, then current_alerts = "None" if sys.stdin.isatty():
current_alerts = "None" if len(alerts) == 0 else ", ".join(alerts.keys()) # list of current alerts, unless there arent any, then current_alerts = "None"
LOGGER.info("No change in alerts.") current_alerts = "None" if len(alerts) == 0 else ", ".join(alerts.keys())
LOGGER.info("Current alerts: %s.", current_alerts) LOGGER.info("No change in alerts.")
LOGGER.info("Current alerts: %s.", current_alerts)
else:
LOGGER.debug("No change in alerts.")
else: else:
LOGGER.debug("No change in alerts.") state["last_alerts"] = alerts
save_state(state)
if __name__ == "__main__": if __name__ == "__main__":

@ -1,7 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
""" """
SkywarnPlus Updater v0.4.2 by Mason Nelson SkywarnPlus Updater v0.4.3 by Mason Nelson
=============================================================================== ===============================================================================
Script to update SkywarnPlus to the latest version. This script will download Script to update SkywarnPlus to the latest version. This script will download
the latest version of SkywarnPlus from GitHub, and then merge the existing the latest version of SkywarnPlus from GitHub, and then merge the existing

@ -1,4 +1,4 @@
# SkywarnPlus v0.4.2 Configuration File # SkywarnPlus v0.4.3 Configuration File
# Author: Mason Nelson (N5LSN/WRKF394) # Author: Mason Nelson (N5LSN/WRKF394)
# Please edit this file according to your specific requirements. # Please edit this file according to your specific requirements.

Loading…
Cancel
Save

Powered by TurnKey Linux.