Fix alerts not being checked properly

This commit is contained in:
April Wormwood 2022-11-15 12:00:45 -07:00 committed by GitHub
parent ffb98eef8f
commit d7da02deba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ async def getAlerts(location):
async with aiohttp.ClientSession() as s:
async with s.get(fetchUrl) as r:
theCode = await r.status
theCode = r.status
#Set the actions based on response code
if theCode == 204:
@ -327,9 +327,7 @@ async def makeRecord():
loop = asyncio.get_running_loop()
global k
# The BERecord XML doesn't need to be written if there's no alerts.
if k > 0:
async with aiofiles.open("./.temp/BERecord.xml", 'a') as BERecord:
async with aiofiles.open("./.temp/BERecord.xml", 'w') as BERecord:
await BERecord.write('<Data type="BERecord">')
await BERecord.close()
@ -347,6 +345,8 @@ async def makeRecord():
await h.write(pretty_xml_as_string[23:])
await h.close()
# The BERecord XML doesn't need to be written if there's no alerts.
if k > 0:
l.info("Sending alert(s) to the IntelliStar 2!")
with open("./.temp/BERecord.i2m", 'rb') as f_in:
with gzip.open("./.temp/BERecord.gz", 'wb') as f_out: