Change Name and changes
This commit is contained in:
parent
9bc1ec3cfd
commit
b9d2254162
|
@ -6,24 +6,28 @@ import time
|
||||||
from colorama import Fore, Back, Style
|
from colorama import Fore, Back, Style
|
||||||
#Various imports for output
|
#Various imports for output
|
||||||
from pushbullet import Pushbullet
|
from pushbullet import Pushbullet
|
||||||
pb = Pushbullet("***REMOVED***")
|
pb = Pushbullet("")
|
||||||
|
|
||||||
geolocator = Nominatim(user_agent="OpenSkyBot", timeout=5)
|
geolocator = Nominatim(user_agent="OpenSkyBot", timeout=5)
|
||||||
api = OpenSkyApi("", "")
|
api = OpenSkyApi("", "")
|
||||||
|
|
||||||
#Set Plane ICAO
|
#Set Plane ICAO
|
||||||
TRACK_PLANE = 'a4c79b'
|
TRACK_PLANE = 'A833535AF'
|
||||||
|
|
||||||
#Pre Set Variables
|
#Pre Set Variables
|
||||||
geo_altitude = None
|
geo_altitude = None
|
||||||
feeding = None
|
feeding = None
|
||||||
last_feeding = None
|
last_feeding = None
|
||||||
#Begin Looping program
|
last_on_ground = None
|
||||||
while True:
|
on_ground = None
|
||||||
#Preset reseting variables
|
|
||||||
invalid_Location = None
|
invalid_Location = None
|
||||||
longitude = None
|
longitude = None
|
||||||
latitude = None
|
latitude = None
|
||||||
|
running_Count = 0
|
||||||
|
#Begin Looping program
|
||||||
|
while True:
|
||||||
|
running_Count += 1
|
||||||
|
print (Back.MAGENTA, "--------", running_Count, "-------------------------------------------------------------", Style.RESET_ALL)
|
||||||
#Get API States for Plane
|
#Get API States for Plane
|
||||||
planeData = api.get_states(icao24=TRACK_PLANE)
|
planeData = api.get_states(icao24=TRACK_PLANE)
|
||||||
print (Fore.YELLOW)
|
print (Fore.YELLOW)
|
||||||
|
@ -31,7 +35,7 @@ while True:
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
|
|
||||||
#Pull Variables from planeData
|
#Pull Variables from planeData
|
||||||
if (planeData != None):
|
if planeData != None:
|
||||||
for dataStates in planeData.states:
|
for dataStates in planeData.states:
|
||||||
longitude = (dataStates.longitude)
|
longitude = (dataStates.longitude)
|
||||||
latitude = (dataStates.latitude)
|
latitude = (dataStates.latitude)
|
||||||
|
@ -46,7 +50,7 @@ while True:
|
||||||
|
|
||||||
|
|
||||||
#Lookup Location of coordinates
|
#Lookup Location of coordinates
|
||||||
if not((longitude == None) and (latitude == None)):
|
if longitude != None and latitude != None:
|
||||||
|
|
||||||
combined = f"{latitude}, {longitude}"
|
combined = f"{latitude}, {longitude}"
|
||||||
location = geolocator.reverse(combined)
|
location = geolocator.reverse(combined)
|
||||||
|
@ -55,10 +59,10 @@ while True:
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
feeding = True
|
feeding = True
|
||||||
else:
|
else:
|
||||||
print (Fore.RED + 'Not Feeding Location')
|
print (Fore.RED + 'Not Feeding')
|
||||||
feeding = False
|
feeding = False
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
print ("Feeding: ", feeding)
|
|
||||||
#Figure if valid location, valid being geopy finds a location
|
#Figure if valid location, valid being geopy finds a location
|
||||||
if feeding:
|
if feeding:
|
||||||
try:
|
try:
|
||||||
|
@ -69,18 +73,17 @@ while True:
|
||||||
else:
|
else:
|
||||||
invalid_Location = True
|
invalid_Location = True
|
||||||
|
|
||||||
|
print ("Invalid Location: ", invalid_Location)
|
||||||
|
|
||||||
if invalid_Location:
|
if invalid_Location:
|
||||||
print (Fore.RED)
|
print (Fore.RED)
|
||||||
print ("Invalid Location: ", invalid_Location)
|
|
||||||
print (geoError)
|
print (geoError)
|
||||||
print ("Likely Over Water or Invalid Location")
|
print ("Likely Over Water or Invalid Location")
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
|
|
||||||
|
|
||||||
#Convert Full address to sep variables
|
#Convert Full address to sep variables only if Valid Location
|
||||||
elif feeding:
|
elif invalid_location is False:
|
||||||
address = location.raw['address']
|
address = location.raw['address']
|
||||||
country = address.get('country', '')
|
country = address.get('country', '')
|
||||||
state = address.get('state', '')
|
state = address.get('state', '')
|
||||||
|
@ -88,9 +91,9 @@ while True:
|
||||||
city = address.get('city', '')
|
city = address.get('city', '')
|
||||||
|
|
||||||
|
|
||||||
print (Fore.YELLOW)
|
# print (Fore.YELLOW)
|
||||||
print ("Address Fields debug: ", address)
|
# print ("Address Fields debug: ", address)
|
||||||
print(Style.RESET_ALL)
|
# print(Style.RESET_ALL)
|
||||||
print (Fore.GREEN)
|
print (Fore.GREEN)
|
||||||
print("Entire Address: ", location.address)
|
print("Entire Address: ", location.address)
|
||||||
print ()
|
print ()
|
||||||
|
@ -111,31 +114,27 @@ while True:
|
||||||
print ("Landed Just Now:", landed)
|
print ("Landed Just Now:", landed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Takeoff Notifcation and Landed
|
#Takeoff Notifcation and Landed
|
||||||
if tookoff:
|
if tookoff:
|
||||||
tookoff_message = ("Just took off from" + " " + city + ", " + state + ", " + country)
|
tookoff_message = ("Just took off from" + " " + (city or county) + ", " + state + ", " + country)
|
||||||
print (tookoff_message)
|
print (tookoff_message)
|
||||||
push = pb.push_note("Elon's Jet", tookoff_message)
|
push = pb.push_note("Elon's Jet", tookoff_message)
|
||||||
|
|
||||||
|
|
||||||
if landed:
|
if landed:
|
||||||
landed_message = ("Landed just now at" + " " + city + ", " + state + ", " + country)
|
landed_message = ("Landed just now at" + " " + (city or county) + ", " + state + ", " + country)
|
||||||
print (landed_message)
|
print (landed_message)
|
||||||
push = pb.push_note("Elon's Jet", landed_message)
|
push = pb.push_note("Elon's Jet", landed_message)
|
||||||
|
|
||||||
|
#Set Variables to compare to next check
|
||||||
last_feeding = feeding
|
last_feeding = feeding
|
||||||
last_geo_altitude = geo_altitude
|
last_geo_altitude = geo_altitude
|
||||||
last_on_ground = on_ground
|
last_on_ground = on_ground
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("Rechecking OpenSky")
|
print ("Rechecking OpenSky")
|
||||||
planeDataMSG = str(planeData)
|
planeDataMSG = str(planeData)
|
||||||
push = pb.push_note("Rechecking OpenSky, OpenSky Debug->", planeDataMSG)
|
push = pb.push_note("Rechecking OpenSky, OpenSky Debug->", planeDataMSG)
|
||||||
|
|
||||||
print (Back.MAGENTA, "--------------------------------------------------------------------")
|
print (Back.MAGENTA, "--------", running_Count, "-------------------------------------------------------------", Style.RESET_ALL)
|
||||||
print(Style.RESET_ALL)
|
print ("")
|
||||||
time.sleep(15)
|
time.sleep(15)
|
Loading…
Reference in New Issue