diff --git a/.gitignore b/.gitignore index 6e9dc46..5853360 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ __pycache__/ # Temp directory .temp/ -conf.json \ No newline at end of file +conf.json +config.json \ No newline at end of file diff --git a/README.md b/README.md index 0978442..96b6d51 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ 3) Use command prompt to enter the directory of the scripts, then install package requirements:
```pip install -r requirements.txt```
4) Copy **config.example.json** to **config.json** and edit to your specific config. -4) Drop your unit's **MachineProductConfiguration.xml** file into the root of the script +4) Drop your unit's **MachineProductCfg.xml** file into the root of the script 5) Run ``py main.py`` ### Attributions & Disclaimers diff --git a/RecordTasks.py b/RecordTasks.py index 8f5b924..962adb8 100644 --- a/RecordTasks.py +++ b/RecordTasks.py @@ -1,5 +1,5 @@ import asyncio -from recordGenerators import Alerts,CurrentObservations,HourlyForecast,DailyForecast, AirQuality, AirportDelays, AchesAndPains, Breathing, HeatingAndCooling, MosquitoActivity, PollenForecast, TideForecast, WateringNeeds +from recordGenerators import alerts,currentObservations,hourlyForecast,dailyForecast, airQuality, airportDelays, achesAndPains, breathing, heatingAndCooling, mosquitoActivity, pollenForecast, tideForecast, wateringNeeds from radar import TWCRadarCollector from datetime import datetime @@ -25,67 +25,67 @@ async def updateSatradTask(): async def alertsTask(): while True: - await Alerts.makeRecord() + await alerts.makeRecord() await asyncio.sleep(60) async def coTask(): while True: - await CurrentObservations.makeDataFile() + await currentObservations.makeDataFile() await asyncio.sleep(5 * 60) # These tasks should be updated every hour async def hfTask(): while True: - await HourlyForecast.makeDataFile() + await hourlyForecast.makeDataFile() await asyncio.sleep(60 * 60) async def dfTask(): while True: - await DailyForecast.makeDataFile() + await dailyForecast.makeDataFile() await asyncio.sleep(60 * 60) async def aqTask(): while True: - await AirQuality.writeData() + await airQuality.writeData() await asyncio.sleep(60 * 60) async def aptTask(): while True: - await AirportDelays.writeData() + await airportDelays.writeData() await asyncio.sleep(60 * 60) async def apTask(): while True: - await AchesAndPains.makeRecord() + await achesAndPains.makeRecord() await asyncio.sleep(60 * 60) async def brTask(): while True: - await Breathing.makeDataFile() + await breathing.makeDataFile() await asyncio.sleep(60 * 60) async def hcTask(): while True: - await HeatingAndCooling.makeRecord() + await heatingAndCooling.makeRecord() await asyncio.sleep(60 * 60) async def maTask(): while True: - await MosquitoActivity.makeRecord() + await mosquitoActivity.makeRecord() await asyncio.sleep(60 * 60) async def pTask(): while True: - await PollenForecast.makeDataFile() + await pollenForecast.makeDataFile() await asyncio.sleep(60 * 60) async def tTask(): while True: - await TideForecast.makeRecord() + await tideForecast.makeRecord() await asyncio.sleep(60 * 60) async def wnTask(): while True: - await WateringNeeds.makeRecord() + await wateringNeeds.makeRecord() await asyncio.sleep(60 * 60) diff --git a/main.py b/main.py index 5278a1c..a287fe1 100644 --- a/main.py +++ b/main.py @@ -5,11 +5,11 @@ import logging,coloredlogs from radar import TWCRadarCollector import os from datetime import datetime -import RecordTasks +import recordTasks # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) l = logging.getLogger(__name__) @@ -19,7 +19,7 @@ useRadarServer = cfg["useRadarServer"] async def createTemp(): """ Used on a first time run, creates necessary files & directories for the message encoder to work properly. """ - if not (os.path.exists('./.temp/')): + if not (os.path.exists('./.temp')): l.info("Creating necessary directories & files..") os.mkdir('./.temp') @@ -33,9 +33,9 @@ async def createTemp(): os.mkdir('./.temp/output/satrad') # Create msgId file for bit.py - async with aiofiles.open('./.temp/msgId.txt', 'w') as msgId: - await msgId.write('410080515') - await msgId.close() + #async with aiofiles.open('./.temp/msgId.txt', 'w') as msgId: + #await msgId.write('694203') + #await msgId.close() else: l.debug(".temp file exists") return @@ -44,21 +44,21 @@ async def createTemp(): async def main(): await createTemp() - mosaicTask = asyncio.create_task(RecordTasks.updateMosaicTask()) - satradTask = asyncio.create_task(RecordTasks.updateSatradTask()) - alertsTask = asyncio.create_task(RecordTasks.alertsTask()) - coTask = asyncio.create_task(RecordTasks.coTask()) - hfTask = asyncio.create_task(RecordTasks.hfTask()) - dfTask = asyncio.create_task(RecordTasks.dfTask()) - aqTask = asyncio.create_task(RecordTasks.aqTask()) - aptTask = asyncio.create_task(RecordTasks.aptTask()) - apTask = asyncio.create_task(RecordTasks.apTask()) - brTask = asyncio.create_task(RecordTasks.brTask()) - hcTask = asyncio.create_task(RecordTasks.hcTask()) - maTask = asyncio.create_task(RecordTasks.maTask()) - pTask = asyncio.create_task(RecordTasks.pTask()) - tTask = asyncio.create_task(RecordTasks.tTask()) - wnTask = asyncio.create_task(RecordTasks.wnTask()) + mosaicTask = asyncio.create_task(recordTasks.updateMosaicTask()) + satradTask = asyncio.create_task(recordTasks.updateSatradTask()) + alertsTask = asyncio.create_task(recordTasks.alertsTask()) + coTask = asyncio.create_task(recordTasks.coTask()) + hfTask = asyncio.create_task(recordTasks.hfTask()) + dfTask = asyncio.create_task(recordTasks.dfTask()) + aqTask = asyncio.create_task(recordTasks.aqTask()) + aptTask = asyncio.create_task(recordTasks.aptTask()) + apTask = asyncio.create_task(recordTasks.apTask()) + brTask = asyncio.create_task(recordTasks.brTask()) + hcTask = asyncio.create_task(recordTasks.hcTask()) + maTask = asyncio.create_task(recordTasks.maTask()) + pTask = asyncio.create_task(recordTasks.pTask()) + tTask = asyncio.create_task(recordTasks.tTask()) + wnTask = asyncio.create_task(recordTasks.wnTask()) # In theory, these should all run concurrently without problems await alertsTask @@ -80,4 +80,4 @@ async def main(): await satradTask if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) diff --git a/py2Lib/bit.old b/py2Lib/bit.old new file mode 100644 index 0000000..158be51 --- /dev/null +++ b/py2Lib/bit.old @@ -0,0 +1,216 @@ +import socket +import sys +import os +import struct +import binascii +import math +import time +import logging,coloredlogs + +# Open the config file and make it accessible via "cfg" +import json +with open("conf.json", "r") as file: + cfg = json.load(file) + +l = logging.getLogger(__name__) +coloredlogs.install() + +MCAST_GRP = cfg["multicastGroup"] +MCAST_IF = cfg["multicastIf"] +BUF_SIZE = 1396 + +MULTICAST_TTL = 2 + +conn = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) +conn.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP,socket.inet_aton(MCAST_GRP)+socket.inet_aton(MCAST_IF)) + +test = b"This is a test" + +def sendFile(files, commands, numSgmts, Pri): + if Pri == 0: + MCAST_PORT = 7787 + elif Pri == 1: + MCAST_PORT = 7788 + else: + l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...") + exit() + #Get the next message ID + with open('./.temp/msgId.txt', "r") as f: + oMsgId = f.read() + msgNum = int(oMsgId) + f.close() + + nMsgNum = msgNum + 1 + h = open('./.temp/msgId.txt', "w") + h.write(str(nMsgNum)) + h.close() + segnmNum = 0 + if Pri == 0: + l.info("Sending Routine Msg-" + str(msgNum) + " on UDP " + MCAST_GRP + " " + str(MCAST_PORT) + "....") + elif Pri == 1: + l.info("Sending High Priority Msg-" + str(msgNum) + " on UDP " + MCAST_GRP + " " + str(MCAST_PORT) + "....") + startFlag = False + + for x, y in zip(files, commands): + size = os.path.getsize(x) + check = size - BUF_SIZE + pToBeSent = size / 1405 + packRounded = math.ceil(pToBeSent) + 1 + numSegments = numSgmts + 3 + total_sent = 0 + payloadLength = 0 + packet_count = 1 + j = 0 + pc = packet_count.to_bytes(1, byteorder='big') + i = 0 + encode1 = bytes(y + 'I2MSG', 'UTF-8') + commandLength = len(y) + encode2 = commandLength.to_bytes(4, byteorder='little') + theCommand = b"".join([encode1, encode2]) + char = '' + new_file = open(x, "ab") + new_file.write(theCommand) # Append command to end of the file + new_file.close() + new_size = os.path.getsize(x) + + if startFlag == False: + #Our 34 byte beginning packet + p1 = struct.pack(">BHHHIIBBBBBBBIBIBBB", 18, 1, 0 , 16, msgNum, 0, segnmNum, 0, 0, 8, numSegments, 3, 0, 0, 8, packRounded, 0, 0, 0) + conn.sendto(p1, (MCAST_GRP, MCAST_PORT)) + startFlag = True + with open(x,"rb") as message: + message.seek(0) + data = message.read(BUF_SIZE) + while data: + packetHeader = struct.pack(">BHHHIIBBB", 18, 1, 0, 1405, msgNum, packet_count, 0, 0, 0) + fec = struct.pack("BHHHIIBBBBBBBI", 18, 1, 1, 8, msgNum, 0, segnmNum, 0, 0, 8, 0, 0, 0, 67108864) + p4 = struct.pack(">BHHHIIBBB", 18, 1, 1, 14, msgNum, 1, segnmNum, 0, 0) + test + conn.sendto(p3, (MCAST_GRP, MCAST_PORT)) + conn.sendto(p4, (MCAST_GRP, MCAST_PORT)) + segnmNum += 1 + w -= 1 + #------------------------------------------------------------------------------------------------------- +def sendCommand(command, Pri, msgNum = None): + if Pri == 0: + MCAST_PORT = 7787 + elif Pri == 1: + MCAST_PORT = 7788 + else: + l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...") + exit() + #Get the next message ID + with open('./.temp/msgId.txt', "r") as f: + oMsgId = f.read() + msgNum = int(oMsgId) + f.close() + + nMsgNum = msgNum + 1 + h = open('./.temp/msgId.txt', "w") + h.write(str(nMsgNum)) + h.close() + segnmNum = 0 + if Pri == 0: + l.info("Sending Routine Msg-" + str(msgNum) + " on UDP " + MCAST_GRP + " " + str(MCAST_PORT) + "....") + elif Pri == 1: + l.info("Sending High Priority Msg-" + str(msgNum) + " on UDP " + MCAST_GRP + " " + str(MCAST_PORT) + "....") + startFlag = False + + for x in command: + bx = bytes(x, 'utf-8') + with open('./.temp/command', 'wb') as c: + c.write(bx) + c.close() + size = os.path.getsize('./.temp/command') + encode1 = bytes('I2MSG', 'UTF-8') + commandLength = size + encode2 = commandLength.to_bytes(4, byteorder='little') + theCommand = b"".join([encode1, encode2]) + with open('./.temp/command', 'ab') as d: + d.write(theCommand) + d.close() + check = size - BUF_SIZE + pToBeSent = size / 1405 + packRounded = math.ceil(pToBeSent) + 1 + numSegments = 4 + total_sent = 0 + payloadLength = 0 + packet_count = 1 + j = 0 + pc = packet_count.to_bytes(4, byteorder='little') + i = 0 + char = '' + new_size = os.path.getsize('./.temp/command') + + if startFlag == False: + #Our 34 byte beginning packet + p1 = struct.pack(">BHHHIIBBBBBBBIBIBBB", 18, 1, 0 , 16, msgNum, 0, segnmNum, 0, 0, 8, numSegments, 3, 0, 0, 8, packRounded, 0, 0, 0) + conn.sendto(p1, (MCAST_GRP, MCAST_PORT)) + startFlag = True + with open('./.temp/Command',"rb") as message: + message.seek(0) + data = message.read(BUF_SIZE) + while data: + packetHeader = struct.pack(">BHHHIIBBB", 18, 1, 0, 1405, msgNum, packet_count, 0, 0, 0) + fec = struct.pack("BHHHIIBBBBBBBI", 18, 1, 1, 8, msgNum, 0, segnmNum, 0, 0, 8, 0, 0, 0, 67108864) + p4 = struct.pack(">BHHHIIBBB", 18, 1, 1, 14, msgNum, 1, segnmNum, 0, 0) + test + conn.sendto(p3, (MCAST_GRP, MCAST_PORT)) + conn.sendto(p4, (MCAST_GRP, MCAST_PORT)) + segnmNum += 1 + w -= 1 + #------------------------------------------------------------------------------------------------------- diff --git a/py2Lib/bit.py b/py2Lib/bit.py index 158be51..334c636 100644 --- a/py2Lib/bit.py +++ b/py2Lib/bit.py @@ -6,10 +6,11 @@ import binascii import math import time import logging,coloredlogs +from pathlib import Path # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) l = logging.getLogger(__name__) @@ -34,14 +35,22 @@ def sendFile(files, commands, numSgmts, Pri): else: l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...") exit() - #Get the next message ID - with open('./.temp/msgId.txt', "r") as f: + + # Create msgId if it doesn't exist + msg_id_file = Path('./.temp/msgId.txt') + if not os.path.exists(msg_id_file): + msg_id_file_p = Path('./.temp/msgId.txt') + msg_id_file_p.parent.mkdir(exist_ok=True, parents=True) + msg_id_file_p.write_text("1") + + # Get the next message ID + with open(msg_id_file, "r") as f: oMsgId = f.read() msgNum = int(oMsgId) f.close() nMsgNum = msgNum + 1 - h = open('./.temp/msgId.txt', "w") + h = open(msg_id_file, "w") h.write(str(nMsgNum)) h.close() segnmNum = 0 @@ -126,14 +135,22 @@ def sendCommand(command, Pri, msgNum = None): else: l.critical("Invalid Priority Flag. 0 = Routine Message 1 = High Priority Message\n\nScript will now terminate...") exit() - #Get the next message ID - with open('./.temp/msgId.txt', "r") as f: + + # Create msgId if it doesn't exist + msg_id_file = Path('./.temp/msgId.txt') + if not os.path.exists(msg_id_file): + msg_id_file_p = Path('./.temp/msgId.txt') + msg_id_file_p.parent.mkdir(exist_ok=True, parents=True) + msg_id_file_p.write_text("1") + + # Get the next message ID + with open(msg_id_file, "r") as f: oMsgId = f.read() msgNum = int(oMsgId) f.close() nMsgNum = msgNum + 1 - h = open('./.temp/msgId.txt', "w") + h = open(msg_id_file, "w") h.write(str(nMsgNum)) h.close() segnmNum = 0 @@ -174,7 +191,7 @@ def sendCommand(command, Pri, msgNum = None): p1 = struct.pack(">BHHHIIBBBBBBBIBIBBB", 18, 1, 0 , 16, msgNum, 0, segnmNum, 0, 0, 8, numSegments, 3, 0, 0, 8, packRounded, 0, 0, 0) conn.sendto(p1, (MCAST_GRP, MCAST_PORT)) startFlag = True - with open('./.temp/Command',"rb") as message: + with open('./.temp/command',"rb") as message: message.seek(0) data = message.read(BUF_SIZE) while data: diff --git a/radar/TWCRadarCollector.py b/radar/TWCRadarCollector.py index b9b23fc..d4ed086 100644 --- a/radar/TWCRadarCollector.py +++ b/radar/TWCRadarCollector.py @@ -9,7 +9,7 @@ from os import path, listdir, remove # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) l = logging.getLogger(__name__) diff --git a/recordGenerators/AchesAndPains.py b/recordGenerators/AchesAndPains.py index 5183a80..323c34b 100644 --- a/recordGenerators/AchesAndPains.py +++ b/recordGenerators/AchesAndPains.py @@ -1,9 +1,9 @@ import shutil import requests import logging,coloredlogs -from py2Lib import bit -import Util.MachineProductCfg as MPC -import records.LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR import gzip from os import remove import xml.dom.minidom @@ -21,7 +21,7 @@ for i in MPC.getPrimaryLocations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -82,4 +82,4 @@ async def makeRecord(): bit.sendFile([file], [command], 1, 0) remove('./.temp/AchesAndPains.i2m') - remove('./.temp/AchesAndPains.gz') \ No newline at end of file + remove('./.temp/AchesAndPains.gz') diff --git a/recordGenerators/AirQuality.py b/recordGenerators/AirQuality.py index b78ea9b..86520c9 100644 --- a/recordGenerators/AirQuality.py +++ b/recordGenerators/AirQuality.py @@ -9,13 +9,9 @@ import aiohttp, aiofiles, asyncio l = logging.getLogger(__name__) coloredlogs.install() -import sys -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR locationIds = [] zipCodes = [] @@ -28,7 +24,7 @@ for i in MPC.getPrimaryLocations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] diff --git a/recordGenerators/AirportDelays.py b/recordGenerators/AirportDelays.py index 83f00f8..2440ef9 100644 --- a/recordGenerators/AirportDelays.py +++ b/recordGenerators/AirportDelays.py @@ -6,13 +6,9 @@ import xml.dom.minidom import logging,coloredlogs import aiohttp, aiofiles, asyncio -import sys -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) coloredlogs.install() @@ -30,7 +26,7 @@ l.debug(airports) # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] diff --git a/recordGenerators/Alerts.py b/recordGenerators/Alerts.py index d761e4d..3665af4 100644 --- a/recordGenerators/Alerts.py +++ b/recordGenerators/Alerts.py @@ -2,7 +2,7 @@ import requests import json import os from datetime import datetime,timedelta -from Util.MachineProductCfg import getAlertZones +from util.machineProductCfg import getAlertZones import time import pytz import xml.dom.minidom @@ -10,11 +10,7 @@ import shutil import gzip import logging,coloredlogs import aiohttp, aiofiles, asyncio - - -import sys -sys.path.append("./py2lib") -import bit +import py2Lib.bit l = logging.getLogger(__name__) coloredlogs.install() @@ -23,7 +19,7 @@ coloredlogs.install() alertLocations = getAlertZones() # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) headlineApiKey = cfg["twcApiKey"] diff --git a/recordGenerators/Breathing.py b/recordGenerators/Breathing.py index d716bc0..9dab8c1 100644 --- a/recordGenerators/Breathing.py +++ b/recordGenerators/Breathing.py @@ -1,5 +1,4 @@ import requests -import sys import gzip import uuid import os @@ -8,12 +7,9 @@ import xml.dom.minidom import logging,coloredlogs import aiohttp, aiofiles, asyncio -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) coloredlogs.install() @@ -31,7 +27,7 @@ l.debug(coopIds, geocodes) # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -94,4 +90,4 @@ async def makeDataFile(): bit.sendFile(files, commands, numFiles, 0) os.remove("./.temp/Breathing.i2m") - os.remove("./.temp/Breathing.gz") \ No newline at end of file + os.remove("./.temp/Breathing.gz") diff --git a/recordGenerators/CurrentObservations.py b/recordGenerators/CurrentObservations.py index c4a4396..d3d693e 100644 --- a/recordGenerators/CurrentObservations.py +++ b/recordGenerators/CurrentObservations.py @@ -8,13 +8,9 @@ import xml.dom.minidom import logging,coloredlogs import aiohttp, aiofiles, asyncio -import sys -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) coloredlogs.install() @@ -35,7 +31,7 @@ for i in MPC.getMetroCities(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] diff --git a/recordGenerators/DailyForecast.py b/recordGenerators/DailyForecast.py index ba8ec02..41f1441 100644 --- a/recordGenerators/DailyForecast.py +++ b/recordGenerators/DailyForecast.py @@ -1,5 +1,4 @@ import requests -import sys import gzip import uuid import os @@ -8,12 +7,9 @@ import xml.dom.minidom import logging,coloredlogs import aiohttp, aiofiles, asyncio -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) coloredlogs.install() @@ -33,7 +29,7 @@ for i in MPC.getMetroCities(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -95,4 +91,4 @@ async def makeDataFile(): bit.sendFile(files, commands, numFiles, 0) os.remove("./.temp/DailyForecast.i2m") - os.remove("./.temp/DailyForecast.gz") \ No newline at end of file + os.remove("./.temp/DailyForecast.gz") diff --git a/recordGenerators/HeatingAndCooling.py b/recordGenerators/HeatingAndCooling.py index 1bebbeb..58f866a 100644 --- a/recordGenerators/HeatingAndCooling.py +++ b/recordGenerators/HeatingAndCooling.py @@ -1,9 +1,9 @@ import shutil import requests import logging,coloredlogs -from py2Lib import bit -import Util.MachineProductCfg as MPC -import records.LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR import gzip from os import remove import xml.dom.minidom @@ -21,7 +21,7 @@ for i in MPC.getPrimaryLocations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -82,4 +82,4 @@ async def makeRecord(): bit.sendFile([file], [command], 1, 0) remove('./.temp/HeatingAndCooling.i2m') - remove('./.temp/HeatingAndCooling.gz') \ No newline at end of file + remove('./.temp/HeatingAndCooling.gz') diff --git a/recordGenerators/HourlyForecast.py b/recordGenerators/HourlyForecast.py index 0c85924..7cb3e48 100644 --- a/recordGenerators/HourlyForecast.py +++ b/recordGenerators/HourlyForecast.py @@ -7,13 +7,9 @@ import xml.dom.minidom import logging,coloredlogs import aiohttp, aiofiles, asyncio, asyncio -import sys -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) coloredlogs.install() @@ -33,7 +29,7 @@ for i in MPC.getMetroCities(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -97,4 +93,4 @@ async def makeDataFile(): bit.sendFile(files, commands, numFiles, 0) os.remove("./.temp/HourlyForecast.i2m") - os.remove("./.temp/HourlyForecast.gz") \ No newline at end of file + os.remove("./.temp/HourlyForecast.gz") diff --git a/recordGenerators/MosquitoActivity.py b/recordGenerators/MosquitoActivity.py index 796903b..94b51e7 100644 --- a/recordGenerators/MosquitoActivity.py +++ b/recordGenerators/MosquitoActivity.py @@ -1,9 +1,9 @@ import shutil import requests import logging,coloredlogs -from py2Lib import bit -import Util.MachineProductCfg as MPC -import records.LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR import gzip from os import remove import xml.dom.minidom @@ -21,7 +21,7 @@ for i in MPC.getPrimaryLocations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -82,4 +82,4 @@ async def makeRecord(): bit.sendFile([file], [command], 1, 0) remove('./.temp/MosquitoActivity.i2m') - remove('./.temp/MosquitoActivity.gz') \ No newline at end of file + remove('./.temp/MosquitoActivity.gz') diff --git a/recordGenerators/PollenForecast.py b/recordGenerators/PollenForecast.py index 89a624f..3d28ca1 100644 --- a/recordGenerators/PollenForecast.py +++ b/recordGenerators/PollenForecast.py @@ -1,5 +1,4 @@ import requests -import sys import gzip import uuid import os @@ -8,12 +7,9 @@ import xml.dom.minidom import logging, coloredlogs import aiohttp, aiofiles, asyncio -sys.path.append("./py2lib") -sys.path.append("./Util") -sys.path.append("./records") -import bit -import MachineProductCfg as MPC -import LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR l = logging.getLogger(__name__) @@ -32,7 +28,7 @@ l.debug(pollenIds, geocodes) # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -94,4 +90,4 @@ async def makeDataFile(): bit.sendFile(files, commands, numFiles, 0) os.remove("./.temp/PollenForecast.i2m") - os.remove("./.temp/PollenForecast.gz") \ No newline at end of file + os.remove("./.temp/PollenForecast.gz") diff --git a/recordGenerators/TideForecast.py b/recordGenerators/TideForecast.py index 771330f..2756297 100644 --- a/recordGenerators/TideForecast.py +++ b/recordGenerators/TideForecast.py @@ -1,9 +1,9 @@ import shutil import logging,coloredlogs import datetime -from py2Lib import bit -import Util.MachineProductCfg as MPC -import records.LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR import gzip from os import remove import xml.dom.minidom @@ -21,7 +21,7 @@ for i in MPC.getTideStations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -91,4 +91,4 @@ async def makeRecord(): bit.sendFile([file], [command], 1, 0) remove('./.temp/TidesForecast.i2m') - remove('./.temp/TidesForecast.gz') \ No newline at end of file + remove('./.temp/TidesForecast.gz') diff --git a/recordGenerators/WateringNeeds.py b/recordGenerators/WateringNeeds.py index c37190f..cd44f4a 100644 --- a/recordGenerators/WateringNeeds.py +++ b/recordGenerators/WateringNeeds.py @@ -1,9 +1,9 @@ import shutil import requests import logging,coloredlogs -from py2Lib import bit -import Util.MachineProductCfg as MPC -import records.LFRecord as LFR +import py2Lib.bit +import util.machineProductCfg as MPC +import records.lfRecord as LFR import gzip from os import remove import xml.dom.minidom @@ -21,7 +21,7 @@ for i in MPC.getPrimaryLocations(): # Open the config file and make it accessible via "cfg" import json -with open("conf.json", "r") as file: +with open("config.json", "r") as file: cfg = json.load(file) apiKey = cfg["twcApiKey"] @@ -81,4 +81,4 @@ async def makeRecord(): bit.sendFile([file], [command], 1, 0) remove('./.temp/WateringNeeds.i2m') - remove('./.temp/WateringNeeds.gz') \ No newline at end of file + remove('./.temp/WateringNeeds.gz') diff --git a/requirements.txt b/requirements.txt index f3d5995..4e3cd99 100644 Binary files a/requirements.txt and b/requirements.txt differ