I am making a program that uses python and the Weather.gov API found Here that can fetch active weather alerts. I have that system working, and posting all active alerts to Discord.
What I want to do now is to have my other python script that makes the alert tones for my radio equipment automatically take the information (E.G. a Tornado Warning) and automatically generate whenever an alert is found.
Ths issue is that I need to run a python file from another one, and all the examples seen Here use functions within the script. I need to run the file as a whole.
my current code takes the data from the API like so:
url = "https://api.weather.gov/alerts/active?status=actual&message_type=alert"
response = requests.get(url)
weatherFeed = json.loads(response.content)
weatherFeed2 = weatherFeed['features']
updated = weatherFeed2[0]['properties']['id']
#Use this line to debug if no data is coming through the line...
##print(weatherFeed)
firstAlert = open("WP.txt", "w")
firstAlert.write(updated)
firstAlert.close()
firstAlert = open("WP.txt", "r")
print("First Alert - Recieved at " + time.strftime("%m-%d-%Y %H:%M:%S", time.gmtime()) + " GMT - ID: "+updated)
print('''
==========================================================
''' + weatherFeed2[0]['properties']['event'] + '''
Sent: ''' + weatherFeed2[0]['properties']['sent'])
if (weatherFeed2[0]['properties']['ends'] != None):
print("Ends: "+weatherFeed2[0]['properties']['ends'])
print("")
if (weatherFeed2[0]['properties']['description'] != None):
print("Event Description:"+weatherFeed2[0]['properties']['description'])
if (weatherFeed2[0]['properties']['instruction'] != None):
print("Instructions: "+weatherFeed2[0]['properties']['instruction'])
print('''
SAME Codes: ''' + ' '.join(map(str, weatherFeed2[0]['properties']['geocode']['SAME'])) + '''
==========================================================
''')
And I need to use the data I get, specifically the alert type weatherFeed2[0]['properties']['event']
and the SAME codes weatherFeed2[0]['properties']['geocode']['SAME']
to run another python file like so:
easencode.py -o WXR -e (EVENT CODES) -f (SAME CODES) -d (DURATION) -t (CURRENT TIME) -c "WACN " -x yes "%cd%\Output\ALERT.wav"
How would one go do this?