Mason10198 / SkywarnPlus

Empowering Asterisk / app_rpt Nodes with Local Alert Intelligence
GNU General Public License v3.0
45 stars 3 forks source link

Small bug: exit w/ error if alert is found, but not yet "active" #29

Closed Mason10198 closed 1 year ago

Mason10198 commented 1 year ago

Small bug that won't be noticed by most users.

Sometimes, the NWS issues alert messages long before the actual event is occurring. For instance, this Heat Advisory where the alert message is effective starting 2023-06-24T03:46:00-05:00, but the alert itself will not be onset until 2023-06-25T10:00:00-05:00. When SkywarnPlus.py detects that the alert is not yet active, it ignores it until it is active. A small error in code organization causes the process to exit before it is fully complete in this scenario.

NWS API Data:

...
"sent": "2023-06-24T03:46:00-05:00",
"effective": "2023-06-24T03:46:00-05:00",
"onset": "2023-06-25T10:00:00-05:00",
"expires": "2023-06-24T15:30:00-05:00",
"ends": "2023-06-25T20:00:00-05:00",
"status": "Actual",
"messageType": "Alert",
"category": "Met",
"severity": "Moderate",
"certainty": "Likely",
"urgency": "Expected",
"event": "Heat Advisory",
"sender": "w-nws.webmaster@noaa.gov",
"senderName": "NWS Little Rock AR",
"headline": "Heat Advisory issued June 24 at 3:46AM CDT until June 25 at 8:00PM CDT by NWS Little Rock AR"
...

Produces these conditions:

Current time: 2023-06-24 17:08:22 Alert start: 2023-06-25 15:00:00 Alert end 2023-06-26 01:00:00

Causes the following error:

root@repeater:/usr/local/bin/SkywarnPlus# ./SkywarnPlus.py
Traceback (most recent call last):
  File "./SkywarnPlus.py", line 1098, in <module>
    main()
  File "./SkywarnPlus.py", line 1018, in main
    alerts = getAlerts(countyCodes)
  File "./SkywarnPlus.py", line 410, in getAlerts
    logger.debug("getAlerts: Skipping alert %s, not active.", event)
UnboundLocalError: local variable 'event' referenced before assignment
Mason10198 commented 1 year ago

Resolved/implemented in v0.2.6