|
|
|
@ -1498,6 +1498,27 @@ def change_id(id):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_title_string(alerts, county_data):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Generate a string of alert titles with county names for use in various displays and messages.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
alert_titles_with_counties = [
|
|
|
|
|
|
|
|
"{} [{}]".format(
|
|
|
|
|
|
|
|
alert,
|
|
|
|
|
|
|
|
", ".join(
|
|
|
|
|
|
|
|
sorted(
|
|
|
|
|
|
|
|
set(
|
|
|
|
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
|
|
|
|
for x in alerts[alert]
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
for alert in alerts
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
return alert_titles_with_counties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def supermon_back_compat(alerts, county_data):
|
|
|
|
def supermon_back_compat(alerts, county_data):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Write alerts to a file for backwards compatibility with Supermon.
|
|
|
|
Write alerts to a file for backwards compatibility with Supermon.
|
|
|
|
@ -1513,17 +1534,8 @@ def supermon_back_compat(alerts, county_data):
|
|
|
|
# Ensure the target directory exists for /tmp/AUTOSKY
|
|
|
|
# Ensure the target directory exists for /tmp/AUTOSKY
|
|
|
|
os.makedirs("/tmp/AUTOSKY", exist_ok=True)
|
|
|
|
os.makedirs("/tmp/AUTOSKY", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
# Construct alert titles with county names
|
|
|
|
# Construct alert titles with county names using generate_title_string function
|
|
|
|
alert_titles_with_counties = [
|
|
|
|
alert_titles_with_counties = generate_title_string(alerts, county_data)
|
|
|
|
"{} [{}]".format(
|
|
|
|
|
|
|
|
alert,
|
|
|
|
|
|
|
|
", ".join(
|
|
|
|
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
|
|
|
|
for x in alerts[alert]
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
for alert in alerts
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check write permissions before writing to the file
|
|
|
|
# Check write permissions before writing to the file
|
|
|
|
if os.access("/tmp/AUTOSKY", os.W_OK):
|
|
|
|
if os.access("/tmp/AUTOSKY", os.W_OK):
|
|
|
|
@ -1934,32 +1946,26 @@ def main():
|
|
|
|
# Determine which alerts have been added since the last check
|
|
|
|
# Determine which alerts have been added since the last check
|
|
|
|
added_alerts = [alert for alert in alerts if alert not in last_alerts]
|
|
|
|
added_alerts = [alert for alert in alerts if alert not in last_alerts]
|
|
|
|
for alert in added_alerts:
|
|
|
|
for alert in added_alerts:
|
|
|
|
counties_str = (
|
|
|
|
counties = sorted(
|
|
|
|
"["
|
|
|
|
set(
|
|
|
|
+ ", ".join(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
for x in alerts[alert]
|
|
|
|
for x in alerts[alert]
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
counties_str = "[" + ", ".join(counties) + "]"
|
|
|
|
LOGGER.info("Added: {} for {}".format(alert, counties_str))
|
|
|
|
LOGGER.info("Added: {} for {}".format(alert, counties_str))
|
|
|
|
pushover_message += "Added: {} for {}\n".format(alert, counties_str)
|
|
|
|
pushover_message += "Added: {} for {}\n".format(alert, counties_str)
|
|
|
|
|
|
|
|
|
|
|
|
# Determine which alerts have been removed since the last check
|
|
|
|
# Determine which alerts have been removed since the last check
|
|
|
|
removed_alerts = [alert for alert in last_alerts if alert not in alerts]
|
|
|
|
removed_alerts = [alert for alert in last_alerts if alert not in alerts]
|
|
|
|
for alert in removed_alerts:
|
|
|
|
for alert in removed_alerts:
|
|
|
|
counties_str = (
|
|
|
|
counties = sorted(
|
|
|
|
"["
|
|
|
|
set(
|
|
|
|
+ ", ".join(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
replace_with_county_name(x["county_code"], county_data)
|
|
|
|
for x in last_alerts[alert]
|
|
|
|
for x in last_alerts[alert]
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
counties_str = "[" + ", ".join(counties) + "]"
|
|
|
|
LOGGER.info("Removed: {} for {}".format(alert, counties_str))
|
|
|
|
LOGGER.info("Removed: {} for {}".format(alert, counties_str))
|
|
|
|
pushover_message += "Removed: {} for {}\n".format(alert, counties_str)
|
|
|
|
pushover_message += "Removed: {} for {}\n".format(alert, counties_str)
|
|
|
|
|
|
|
|
|
|
|
|
@ -1972,43 +1978,34 @@ def main():
|
|
|
|
changed_alerts, changes_details = detect_county_changes(last_alerts, alerts)
|
|
|
|
changed_alerts, changes_details = detect_county_changes(last_alerts, alerts)
|
|
|
|
|
|
|
|
|
|
|
|
for alert, details in changes_details.items():
|
|
|
|
for alert, details in changes_details.items():
|
|
|
|
old_counties_str = (
|
|
|
|
old_counties = sorted(
|
|
|
|
"["
|
|
|
|
set(
|
|
|
|
+ ", ".join(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
for county in details["old"]
|
|
|
|
for county in details["old"]
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
old_counties_str = "[" + ", ".join(old_counties) + "]"
|
|
|
|
|
|
|
|
|
|
|
|
added_msg = ""
|
|
|
|
added_msg = ""
|
|
|
|
if details["added"]:
|
|
|
|
if details["added"]:
|
|
|
|
added_counties_str = (
|
|
|
|
added_counties = sorted(
|
|
|
|
"["
|
|
|
|
set(
|
|
|
|
+ ", ".join(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
for county in details["added"]
|
|
|
|
for county in details["added"]
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
added_counties_str = "[" + ", ".join(added_counties) + "]"
|
|
|
|
added_msg = "is now also affecting {}".format(added_counties_str)
|
|
|
|
added_msg = "is now also affecting {}".format(added_counties_str)
|
|
|
|
|
|
|
|
|
|
|
|
removed_msg = ""
|
|
|
|
removed_msg = ""
|
|
|
|
if details["removed"]:
|
|
|
|
if details["removed"]:
|
|
|
|
removed_counties_str = (
|
|
|
|
removed_counties = sorted(
|
|
|
|
"["
|
|
|
|
set(
|
|
|
|
+ ", ".join(
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
replace_with_county_name(county, county_data)
|
|
|
|
for county in details["removed"]
|
|
|
|
for county in details["removed"]
|
|
|
|
]
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
+ "]"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
removed_counties_str = "[" + ", ".join(removed_counties) + "]"
|
|
|
|
removed_msg = "is no longer affecting {}".format(removed_counties_str)
|
|
|
|
removed_msg = "is no longer affecting {}".format(removed_counties_str)
|
|
|
|
|
|
|
|
|
|
|
|
# Combining the log messages
|
|
|
|
# Combining the log messages
|
|
|
|
@ -2130,10 +2127,14 @@ def main():
|
|
|
|
alert_details = []
|
|
|
|
alert_details = []
|
|
|
|
for alert, counties in alerts.items():
|
|
|
|
for alert, counties in alerts.items():
|
|
|
|
counties_str = ", ".join(
|
|
|
|
counties_str = ", ".join(
|
|
|
|
[
|
|
|
|
sorted(
|
|
|
|
replace_with_county_name(county["county_code"], county_data)
|
|
|
|
set(
|
|
|
|
|
|
|
|
replace_with_county_name(
|
|
|
|
|
|
|
|
county["county_code"], county_data
|
|
|
|
|
|
|
|
)
|
|
|
|
for county in counties
|
|
|
|
for county in counties
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
alert_details.append("{} ({})".format(alert, counties_str))
|
|
|
|
alert_details.append("{} ({})".format(alert, counties_str))
|
|
|
|
current_alerts = "; ".join(alert_details)
|
|
|
|
current_alerts = "; ".join(alert_details)
|
|
|
|
|