diff --git a/radar/TWCRadarProcessor.py b/radar/TWCRadarProcessor.py
index 4045608..132c0ab 100644
--- a/radar/TWCRadarProcessor.py
+++ b/radar/TWCRadarProcessor.py
@@ -293,9 +293,12 @@ async def makeRadarImages():
# Remove the tileset as we don't need it anymore!
rmtree(f'tiles/{times[i]}')
- # Composite images for the i2
+ # Composite images for the i2
+ imgsProcessed = 0
for img in framesToComposite:
+ imgsProcessed += 1
l.debug("Attempting to composite " + img)
+ l.info(f"Processing radar frame {imgsProcessed} / 36")
# Crop the radar images something that the i2 will actually take
img_raw = wandImage(filename=img)
diff --git a/recordGenerators/Alerts.py b/recordGenerators/Alerts.py
index 6544e2c..c25d625 100644
--- a/recordGenerators/Alerts.py
+++ b/recordGenerators/Alerts.py
@@ -8,8 +8,12 @@ import pytz
import xml.dom.minidom
import shutil
import gzip
+import logging,coloredlogs
import py2Lib.bit as bit
+l = logging.getLogger(__name__)
+coloredlogs.install()
+
#Zones/Counties to fetch alerts for
zones = getZones()
@@ -17,11 +21,6 @@ zones = getZones()
headlineApiKey = '21d8a80b3d6b444998a80b3d6b1449d3'
detailsApiKey = '21d8a80b3d6b444998a80b3d6b1449d3'
-#Where does this script live? Put path below.
-#Sorry I'm too lazy to program this script figure it out itself.
-#TODO: Find the path automatically
-path = 'D:\\PythonScripts\\Alerts'
-
k = 0
def getAlerts(location):
global k
@@ -65,7 +64,7 @@ def getAlerts(location):
pass
#Alright lets map our headline variables.
- print('Found Alert for ' + location + '\n')
+ l.debug('Found Alert for ' + location + '\n')
dataH = response.json()
alertsRoot = dataH['alerts']
@@ -91,11 +90,11 @@ def getAlerts(location):
locationType = 'Z'
#theIdent = str(Identifier)
- thecheck = open(path + '\\Output\\alertmanifest.txt', "r")
+ thecheck = open('alertmanifest.txt', "r")
check = thecheck.read()
if check.find(Identifier) != -1:
- print("Alert already sent...")
+ l.debug("Alert already sent...")
return
k += 1 #We have an alert to send!
@@ -301,55 +300,52 @@ def getAlerts(location):
alertMsg = 'NOT_USED' + x['productIdentifier'] + 'NOT_USED' + Action + '' + x['officeCode'] + '' + x['phenomena'] + '' + x['significance'] + '' + x['eventTrackingNumber'] + '' + x['eventDescription'] + 'NOT_USED' + EndTimeUTC + '' + str(x['severityCode']) + 'NOT_USED' + expireTimeUTC + '' + location + '' + x['adminDistrictCode'] + 'NOT_USEDNOT_USEDNOT_USED' + x['identifier'] + '' + processTime + '' + issueTimeUtc + '' + x['headlineText'] + '' + vocalCode + 'NOT_USED' + description + 'NOT_USED' + location + '_' + x['phenomena'] + '_' + x['significance'] + '_' + x['eventTrackingNumber'] + '_' + x['officeCode'] + ''
#Append BERecord
- with open(path + '\\Output\\BERecord.xml', "a") as b:
+ with open('D:\\BERecord.xml', "a") as b:
b.write(alertMsg)
b.close()
#Add our alert to the manifest so we don't keep sending in the same alert every 60 seconds unless an update is issued.
- with open(path + '\\Output\\alertmanifest.txt', "a") as c:
+ with open('alertmanifest.txt', "a") as c:
c.write('\n' + location + '_' + x['phenomena'] + '_' + x['significance'] + '_' + str(x['processTimeUTC']))
c.close()
# TODO: This should be converted into a function so it works better with async, that way we're not getting hung up on that time.sleep() call.
-# n = 0
-# while n==0:
-# #Start our XML File
-# with open(path + '\\Output\\BERecord.xml', "w") as e:
-# e.write('')
-# e.close()
-# for i in interestList:
-# getAlerts(i)
-# #Close our XML File
-# with open(path + '\\Output\\BERecord.xml', "a") as d:
-# d.write('')
-# d.close()
-# dom = xml.dom.minidom.parse(path + '\\Output\\BERecord.xml')
-# pretty_xml_as_string = dom.toprettyxml(indent = " ")
-
-# with open(path + '\\Output\\BERecord.i2m', "w") as h:
-# h.write(pretty_xml_as_string[23:])
-# h.close()
-# if k > 0:
-# with open(path + '\\Output\\BERecord.i2m', 'rb') as f_in:
-# with gzip.open(path + '\\Output\\BERecord.gz', 'wb') as f_out:
-# shutil.copyfileobj(f_in, f_out)
-
-# files = []
-# commands = []
-# gZipFile = path + '\\Output\\BERecord.gz'
-# files.append(gZipFile)
-# command = commands.append('')
-# bit.sendFile(files, commands, 1, 0)
-# os.remove(gZipFile)
-# k = 0
-# os.remove(path + '\\Output\\BERecord.xml')
-# #os.remove(path + '\\Output\\BERecord.i2m')
-
-# print('Will sleep for 60 seconds...\n')
-# time.sleep(60)
+def makeRecord():
+ with open("D:\\BERecord.xml", 'a') as BERecord:
+ BERecord.write('")
+ BERecord.close()
-def makeBERecord():
- pass
\ No newline at end of file
+ dom = xml.dom.minidom.parse("D:\\BERecord.xml")
+ pretty_xml_as_string = dom.toprettyxml(indent = " ")
+
+ with open("D:\\BERecord.i2m", 'w') as h:
+ h.write(pretty_xml_as_string[23:])
+ h.close()
+
+ # If we don't need to send the i2 an alert, we don't need to gzip it.
+ if k > 0:
+ l.info("Sending alert(s) to the IntelliStar 2!")
+ with open("D:\\BERecord.i2m", 'rb') as f_in:
+ with gzip.open("D:\\BERecord.gz", 'wb') as f_out:
+ shutil.copyfileobj(f_in, f_out)
+
+ files = []
+ commands = []
+ gZipFile = "D:\\BERecord.gz"
+ files.append(gZipFile)
+ command = commands.append('')
+ bit.sendFile(files, commands, 1, 0)
+ os.remove(gZipFile)
+ k = 0
+
+ os.remove("D:\\BERecord.xml")
+
\ No newline at end of file