import shutil
import requests
import logging,coloredlogs
from py2Lib import bit
import Util.MachineProductCfg as MPC
import records.LFRecord as LFR
import gzip
from os import remove
import xml.dom.minidom
l = logging.getLogger(__name__)
coloredlogs.install()
geocodes = []
coopIds = []
for i in MPC.getPrimaryLocations():
coopIds.append(LFR.getCoopId(i))
geocodes.append(LFR.getLatLong(i).replace('/', ','))
apiKey = "21d8a80b3d6b444998a80b3d6b1449d3"
def getData(coopId, geocode):
fetchUrl = f"https://api.weather.com/v2/indices/heatCool/daypart/7day?geocode={geocode}&language=en-US&format=xml&apiKey={apiKey}"
res = requests.get(fetchUrl)
if res.status_code != 200:
l.error("DO NOT REPORT THE ERROR BELOW")
l.error(f"Failed to write HeatingAndCooling record -- Status code {res.status_code}")
return
data = res.text()
data = data[63:-26]
i2Doc = f'\n {data}\n {coopId}\n '
f = open('./.temp/HeatingAndCooling.i2m', 'a')
f.write(i2Doc)
f.close()
def makeRecord():
l.info("Writing HeatingAndCooling record.")
header = '