Skip to content

Commit

Permalink
Update locationdata.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SpudGunMan committed Dec 12, 2024
1 parent f759e2e commit 5718a43
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/locationdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,18 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False):
# extract values from XML
sameVal = "NONE"
geocode_value = "NONE"
description = ""
try:
eventCode_table = info.getElementsByTagName("eventCode")[0]
alertType = eventCode_table.getElementsByTagName("valueName")[0].childNodes[0].nodeValue
alertCode = eventCode_table.getElementsByTagName("value")[0].childNodes[0].nodeValue
headline = info.getElementsByTagName("headline")[0].childNodes[0].nodeValue
description = info.getElementsByTagName("description")[0].childNodes[0].nodeValue

# if no description
if len(info.getElementsByTagName("description")) > 0:
description = headline
else:
description = info.getElementsByTagName("description")[0].childNodes[0].nodeValue

area_table = info.getElementsByTagName("area")[0]
areaDesc = area_table.getElementsByTagName("areaDesc")[0].childNodes[0].nodeValue
Expand All @@ -513,7 +519,8 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False):
if geocode_type == "SAME":
sameVal = geocode_value
except Exception as e:
logger.warning(f"System: iPAWS Error extracting alert data: {e}")
logger.warning(f"System: iPAWS Error extracting alert data: {link}")
#print(f"DEBUG: {info.toprettyxml()}")
continue

# check if the alert is for the current location, if wanted keep alert
Expand Down Expand Up @@ -552,4 +559,3 @@ def getIpawsAlert(lat=0, lon=0, shortAlerts = False):
alert = NO_ALERTS

return alert

0 comments on commit 5718a43

Please sign in to comment.