├── __init__.py ├── ExImages ├── GMapEX.png ├── DiscordEX.png ├── TwitterEX.png ├── PushbulletEX.png └── tar1090appendedEX.png ├── .gitignore ├── docker-compose.yml ├── defTweet.py ├── Pipfile ├── defDiscord.py ├── Dockerfile ├── defMap.py ├── defOpenSky.py ├── mictronics_parse.py ├── configs ├── plane1.ini └── mainconf.ini ├── PseudoCode.md ├── calculate_headings.py ├── Refrences.md ├── defAirport.py ├── modify_image.py ├── defADSBX.py ├── defSS.py ├── README.md ├── __main__.py ├── Pipfile.lock ├── LICENSE └── planeClass.py /__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ExImages/GMapEX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/plane-notify/HEAD/ExImages/GMapEX.png -------------------------------------------------------------------------------- /ExImages/DiscordEX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/plane-notify/HEAD/ExImages/DiscordEX.png -------------------------------------------------------------------------------- /ExImages/TwitterEX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/plane-notify/HEAD/ExImages/TwitterEX.png -------------------------------------------------------------------------------- /ExImages/PushbulletEX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/plane-notify/HEAD/ExImages/PushbulletEX.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/settings.json 2 | pythonenv3.8/ 3 | __pycache__ 4 | dependencies 5 | testing 6 | lookup_route.py -------------------------------------------------------------------------------- /ExImages/tar1090appendedEX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sahilxkhadka/plane-notify/HEAD/ExImages/tar1090appendedEX.png -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | plane-notify: 4 | platform: linux/amd64 5 | build: 6 | context: . 7 | volumes: 8 | - ./:/plane-notify 9 | -------------------------------------------------------------------------------- /defTweet.py: -------------------------------------------------------------------------------- 1 | # Authenticate to Twitter 2 | def tweepysetup(config): 3 | import tweepy 4 | #DOCU 5 | #https://realpython.com/twitter-bot-python-tweepy/ 6 | auth = tweepy.OAuthHandler(config.get('TWITTER', 'CONSUMER_KEY'), config.get('TWITTER', 'CONSUMER_SECRET')) 7 | auth.set_access_token(config.get('TWITTER', 'ACCESS_TOKEN'), config.get('TWITTER', 'ACCESS_TOKEN_SECRET')) 8 | tweet_api = tweepy.API(auth, wait_on_rate_limit=True) 9 | return tweet_api -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | name = "pypi" 3 | url = "https://pypi.org/simple" 4 | verify_ssl = true 5 | 6 | [dev-packages] 7 | 8 | [packages] 9 | colorama = "*" 10 | geopy = "*" 11 | tabulate = "*" 12 | pytz = "*" 13 | pillow = "*" 14 | tweepy = "*" 15 | "pushbullet.py" = "*" 16 | discord-webhook = "*" 17 | selenium = "*" 18 | opensky-api = {editable = true, git = "https://github.com/openskynetwork/opensky-api.git", subdirectory = "python"} 19 | webdriver-manager = "*" 20 | shapely = "*" 21 | 22 | [requires] 23 | python_version = "3.9" 24 | -------------------------------------------------------------------------------- /defDiscord.py: -------------------------------------------------------------------------------- 1 | def sendDis(message, config, file_name = None, role_id = None): 2 | import requests 3 | from discord_webhook import DiscordWebhook 4 | if role_id != None: 5 | message += f" <@&{role_id}>" 6 | webhook = DiscordWebhook(url=config.get('DISCORD', 'URL'), content=message[0:1999], username=config.get('DISCORD', 'USERNAME')) 7 | if file_name != None: 8 | with open(file_name, "rb") as f: 9 | webhook.add_file(file=f.read(), filename=file_name) 10 | try: 11 | webhook.execute() 12 | except requests.exceptions.RequestException: 13 | pass -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | 3 | WORKDIR /plane-notify 4 | 5 | COPY . . 6 | 7 | # Set the Chrome repo. 8 | RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ 9 | && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list 10 | 11 | # Install Chrome. 12 | RUN apt-get update && apt-get -y install google-chrome-stable 13 | 14 | # Add pipenv 15 | RUN pip install pipenv==2021.5.29 16 | 17 | # Install dependencies 18 | RUN pipenv install 19 | 20 | # Added needed folder for plane-notify process 21 | RUN mkdir /home/plane-notify 22 | 23 | CMD pipenv run python /plane-notify/__main__.py -------------------------------------------------------------------------------- /defMap.py: -------------------------------------------------------------------------------- 1 | def getMap(mapLocation, file_name): 2 | import requests 3 | import configparser 4 | config = configparser.ConfigParser() 5 | config.read('./configs/mainconf.ini') 6 | api_key = config.get('GOOGLE', 'API_KEY') 7 | url = "https://maps.googleapis.com/maps/api/staticmap?" 8 | 9 | center = str(mapLocation) 10 | zoom = 9 11 | 12 | r = requests.get(url + "center=" + center + "&zoom=" + 13 | str(zoom) + "&size=800x800 &key=" + 14 | api_key + "&sensor=false") 15 | 16 | # wb mode is stand for write binary mode 17 | f = open(file_name, 'wb') 18 | 19 | # r.content gives content, 20 | # in this case gives image 21 | f.write(r.content) 22 | 23 | # close method of file object 24 | # save and close the file 25 | f.close() -------------------------------------------------------------------------------- /defOpenSky.py: -------------------------------------------------------------------------------- 1 | def pull_opensky(planes): 2 | import configparser 3 | main_config = configparser.ConfigParser() 4 | main_config.read('./configs/mainconf.ini') 5 | from opensky_api import OpenSkyApi 6 | planeData = None 7 | opens_api = OpenSkyApi(username= None if main_config.get('OPENSKY', 'USERNAME').upper() == "NONE" else main_config.get('OPENSKY', 'USERNAME'), password= None if main_config.get('OPENSKY', 'PASSWORD').upper() == "NONE" else main_config.get('OPENSKY', 'PASSWORD').upper()) 8 | failed = False 9 | icao_array = [] 10 | for key in planes.keys(): 11 | icao_array.append(key.lower()) 12 | try: 13 | planeData = opens_api.get_states(time_secs=0, icao24=icao_array) 14 | except Exception as e: 15 | print ("OpenSky Error", e) 16 | failed = True 17 | return planeData, failed -------------------------------------------------------------------------------- /mictronics_parse.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | folder = os.getcwd() + "/dependencies" 4 | def get_aircraft_reg_by_icao(icao): 5 | with open(folder + '/aircrafts.json') as aircrafts_json: 6 | aircraft = json.load(aircrafts_json) 7 | try: 8 | reg = aircraft[icao.upper()][0] 9 | except KeyError: 10 | reg = None 11 | return reg 12 | def get_type_code_by_icao(icao): 13 | with open(folder + '/aircrafts.json') as aircrafts_json: 14 | aircraft = json.load(aircrafts_json) 15 | try: 16 | type_code = aircraft[icao.upper()][1] 17 | except KeyError: 18 | type_code = None 19 | return type_code 20 | 21 | def get_type_desc(t): 22 | with open(folder + '/types.json') as types_json: 23 | types = json.load(types_json) 24 | return types[t.upper()] 25 | 26 | def get_db_ver(): 27 | with open(folder + '/dbversion.json') as dbver_json: 28 | dbver = json.load(dbver_json) 29 | return dbver["version"] 30 | def test(): 31 | print(get_aircraft_reg_by_icao("A835AF")) 32 | print(get_type_code_by_icao("A835AF")) 33 | print(get_type_desc("GLF6")) 34 | print(get_db_ver()) 35 | #test() -------------------------------------------------------------------------------- /configs/plane1.ini: -------------------------------------------------------------------------------- 1 | [DATA] 2 | #Plane to track, based of ICAO or ICAO24 which is the unique transponder address of a plane. 3 | ICAO = icaohere 4 | 5 | #Optional Per Plane Override 6 | #DATA_LOSS_MINS = 20 7 | 8 | [MAP] 9 | #Map to create from Google Static Maps or screenshot global tar1090 from globe.adsbexchange.com 10 | #Enter GOOGLESTATICMAP or ADSBX 11 | OPTION = ADSBX 12 | #Tar1090 overlays option, should be seperated by comma no space, remove option all together to disable any 13 | OVERLAYS = nexrad 14 | 15 | [AIRPORT] 16 | #Requires a list of airport types, this plane could land/takeoff at 17 | #Choices: small_airport, medium_airport, large_airport, heliport, seaplane_base 18 | TYPES = [small_airport, medium_airport, large_airport] 19 | 20 | #TITLE for Twitter, PB and Discord are Just text added to the front of each message/tweet sent 21 | [TWITTER] 22 | ENABLE = FALSE 23 | TITLE = 24 | CONSUMER_KEY = ckhere 25 | CONSUMER_SECRET = cshere 26 | ACCESS_TOKEN = athere 27 | ACCESS_TOKEN_SECRET = atshere 28 | 29 | [PUSHBULLET] 30 | ENABLE = FALSE 31 | TITLE = Title Of Pushbullet message 32 | API_KEY = apikey 33 | CHANNEL_TAG = channeltag 34 | 35 | [DISCORD] 36 | ENABLE = FALSE 37 | #WEBHOOK URL https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks 38 | URL = webhookurl 39 | #Role to tag optional, the role ID 40 | ROLE_ID = 41 | Title = 42 | USERNAME = plane-notify -------------------------------------------------------------------------------- /configs/mainconf.ini: -------------------------------------------------------------------------------- 1 | [DATA] 2 | #Source to pull data from 3 | #SHOULD BE ADSBX which is ADS-B Exchange or OPENS which is OpenSky 4 | #By default configured with OpenSky which anyone can use without a login 5 | #ADS-B Exchange has better data but is not avalible unless you feed their network or pay. 6 | SOURCE = OPENS 7 | #Default amount of time after data loss to trigger a landing when under 10k ft 8 | DATA_LOSS_MINS = 5 9 | #Failover from one source to the other, only enable if you have both sources setup. 10 | FAILOVER = FALSE 11 | #Timezone if you want your own time to show in the console, if invalid will be set to UTC. 12 | #List of TZs names https://en.wikipedia.org/wiki/List_of_tz_database_time_zones 13 | TZ = UTC 14 | 15 | #ADS-B Exchange https://www.adsbexchange.com/data/ 16 | [ADSBX] 17 | API_KEY = apikey 18 | API_VERSION = 1 19 | 20 | #ADSBX API Proxy, https://gitlab.com/jjwiseman/adsbx-api-proxy, v2 input, v1 or v2 output from proxy 21 | ENABLE_PROXY = FALSE 22 | #Full URL http://host:port 23 | PROXY_HOST = 24 | 25 | #OpenSky https://opensky-network.org/apidoc/index.html 26 | #When using without your own login user and pass should be None 27 | [OPENSKY] 28 | USERNAME = None 29 | PASSWORD = None 30 | 31 | [GOOGLE] 32 | #API KEY for Google Static Maps only if you using this on any of the planes. 33 | API_KEY = googleapikey 34 | 35 | #Used for failover messages and program exits notifcation 36 | [DISCORD] 37 | ENABLE = FALSE 38 | USERNAME = usernamehere 39 | URL = webhookurl -------------------------------------------------------------------------------- /PseudoCode.md: -------------------------------------------------------------------------------- 1 | ### How It works 2 | - Takes data about every (x seconds configurable) from OpenSky Network or ADS-B Exchange and compares it to previous data with what I've defined as a landing or takeoff event. 3 | - A takeoff event is the plane is not on the ground, below 10k feet and ((previously no data and now getting data) or was previously on the ground). 4 | - A landing event is previously below 10k feet and (previously getting data, no longer getting data and previously not on the ground) or (now on the ground and previously not on the ground). 5 | - Given the coordinates of the aircraft the nearest airport is found in an airport database from the distance is calculated using the Haversine formula. The state, region and country are also found in this database with the airport. 6 | - At the time of takeoff a takeoff time is set, which is referenced in the landing event to calculate approximate total flight time. 7 | - A Static map image is created based off location name. (Google Static Maps API) or a screenshot of is created using Selenium/ChromeDriver The selected plane is locked on in the screenshot. 8 | - If the landing event or takeoff event is true, It will output to any of the following built-in output methods. (Twitter, Pushbullet, and Discord all of which can be setup and enabled in each planes config file. Outputs the location name, map image and flight time on landing. (Tweepy and "Pushbullet.py" and Discord_webhooks) -------------------------------------------------------------------------------- /calculate_headings.py: -------------------------------------------------------------------------------- 1 | def calculate_from_bearing(frm, to): 2 | """Calculate inital bearing from one coordinate to next (two tuples of coordinates(lat/lng) in degrees in, returns single bearing)""" 3 | #https://gis.stackexchange.com/questions/228656/finding-compass-direction-between-two-distant-gps-points 4 | from math import atan2, cos, radians, sin, degrees 5 | frm = (radians(frm[0]), radians(frm[1])) 6 | to = (radians(to[0]), radians(to[1])) 7 | y = sin(to[1]- frm[1]) * cos(to[0]) 8 | x = cos(frm[0]) * sin(to[0]) - sin(frm[0]) * cos(to[0]) * cos(to[1]-frm[1]) 9 | from_bearing = degrees(atan2(y, x)) 10 | if from_bearing < 0: 11 | from_bearing += 360 12 | return from_bearing 13 | def calculate_cardinal(d): 14 | """Finds cardinal direction from bearing degree""" 15 | dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW'] 16 | ix = int(round(d / (360. / len(dirs)))) 17 | card = dirs[ix % len(dirs)] 18 | print(card) 19 | return card 20 | def calculate_deg_change(new_heading, original_heading): 21 | """Calculates change between two headings, returns negative degree if change is left, positive if right""" 22 | normal = abs(original_heading-new_heading) 23 | across_inital = 360 - abs(original_heading-new_heading) 24 | if across_inital < normal: 25 | direction = "left" if original_heading < new_heading else "right" 26 | track_change = across_inital 27 | else: 28 | direction = "right" if original_heading < new_heading else "left" 29 | track_change = normal 30 | if direction == "left": 31 | track_change *= -1 32 | print(f"Track change of {track_change}° which is {direction}") 33 | return track_change 34 | 35 | -------------------------------------------------------------------------------- /Refrences.md: -------------------------------------------------------------------------------- 1 | # Reference Links 2 | 3 | ## ADSB Exchange 4 | 5 | - 6 | - 7 | 8 | ## OpenSky 9 | 10 | - 11 | - 12 | 13 | ## GeoPy - Location Name Lookup 14 | 15 | - 16 | - 17 | 18 | ## Colorama 19 | 20 | - 21 | 22 | ## Google Static Maps 23 | 24 | - 25 | 26 | ## Twitter Tutorial 27 | 28 | - 29 | 30 | ## Pushbullet 31 | 32 | - 33 | 34 | ## Discord Webhooks 35 | 36 | - 37 | - 38 | 39 | ## Selenium - ChromeDriver, Screenshot ADSBX 40 | 41 | - 42 | - 43 | - 44 | - 45 | - 46 | - 47 | - 48 | - 49 | 50 | ## Web Driver Manager 51 | 52 | 53 | 54 | ## Tabulate 55 | 56 | - 57 | 58 | ## Nearest Airport 59 | 60 | - 61 | 62 | ### OpenFlights / airports.dat 63 | 64 | - 65 | 66 | ### OurAirports / airports.csv / regions.csv 67 | 68 | - 69 | -------------------------------------------------------------------------------- /defAirport.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import math 3 | def add_airport_region(airport_dict): 4 | #Get full region/state name from iso region name 5 | with open('./dependencies/regions.csv', 'r', encoding='utf-8') as regions_csv: 6 | regions_csv = csv.DictReader(filter(lambda row: row[0]!='#', regions_csv)) 7 | for region in regions_csv: 8 | if region['code'] == airport_dict['iso_region']: 9 | airport_dict['region'] = region['name'] 10 | return airport_dict 11 | def getClosestAirport(latitude, longitude, allowed_types): 12 | from geopy.distance import geodesic 13 | plane = (latitude, longitude) 14 | with open('./dependencies/airports.csv', 'r', encoding='utf-8') as airport_csv: 15 | airport_csv_reader = csv.DictReader(filter(lambda row: row[0]!='#', airport_csv)) 16 | for airport in airport_csv_reader: 17 | if airport['type'] in allowed_types: 18 | airport_coord = float(airport['latitude_deg']), float(airport['longitude_deg']) 19 | airport_dist = float((geodesic(plane, airport_coord).mi)) 20 | if "closest_airport_dict" not in locals(): 21 | closest_airport_dict = airport 22 | closest_airport_dist = airport_dist 23 | elif airport_dist < closest_airport_dist: 24 | closest_airport_dict = airport 25 | closest_airport_dist = airport_dist 26 | closest_airport_dict['distance_mi'] = closest_airport_dist 27 | #Convert indent key to icao key as its labeled icao in other places not ident 28 | closest_airport_dict['icao'] = closest_airport_dict.pop('gps_code') 29 | closest_airport_dict = add_airport_region(closest_airport_dict) 30 | return closest_airport_dict 31 | def get_airport_by_icao(icao): 32 | with open('./dependencies/airports.csv', 'r', encoding='utf-8') as airport_csv: 33 | airport_csv_reader = csv.DictReader(filter(lambda row: row[0]!='#', airport_csv)) 34 | for airport in airport_csv_reader: 35 | if airport['gps_code'] == icao: 36 | matching_airport = airport 37 | #Convert indent key to icao key as its labeled icao in other places not ident 38 | matching_airport['icao'] = matching_airport.pop('gps_code') 39 | break 40 | matching_airport = add_airport_region(matching_airport) 41 | return matching_airport -------------------------------------------------------------------------------- /modify_image.py: -------------------------------------------------------------------------------- 1 | def append_airport(filename, airport): 2 | from PIL import Image, ImageDraw, ImageFont 3 | distance_mi = airport['distance_mi'] 4 | icao = airport['icao'] 5 | iata = airport['iata_code'] 6 | distance_km = distance_mi * 1.609 7 | 8 | # create Image object with the input image 9 | image = Image.open(filename) 10 | # initialise the drawing context with 11 | # the image object as background 12 | draw = ImageDraw.Draw(image) 13 | 14 | #Setup fonts 15 | fontfile = "./dependencies/Roboto-Regular.ttf" 16 | font = ImageFont.truetype(fontfile, 14) 17 | mini_font = ImageFont.truetype(fontfile, 12) 18 | head_font = ImageFont.truetype(fontfile, 16) 19 | 20 | #Setup Colors 21 | black = 'rgb(0, 0, 0)' # Black 22 | white = 'rgb(255, 255, 255)' # White 23 | navish = 'rgb(0, 63, 75)' 24 | whitish = 'rgb(248, 248, 248)' 25 | #Info Box 26 | draw.rectangle(((325, 760), (624, 800)), fill= white, outline=black) 27 | #Header Box 28 | draw.rectangle(((401, 738), (549, 760)), fill= navish) 29 | #ADSBX Logo 30 | draw.rectangle(((658, 762), (800, 782)), fill= white) 31 | adsbx = Image.open("./dependencies/ADSBX_Logo.png") 32 | adsbx = adsbx.resize((25, 25), Image.ANTIALIAS) 33 | image.paste(adsbx, (632, 757), adsbx) 34 | #Create Text 35 | #ADSBX Credit 36 | (x, y) = (660, 760) 37 | text = "adsbexchange.com" 38 | draw.text((x, y), text, fill=black, font=head_font) 39 | #Nearest Airport Header 40 | (x, y) = (422, 740) 41 | text = "Nearest Airport" 42 | draw.text((x, y), text, fill=white, font=head_font) 43 | #ICAO | IATA 44 | (x, y) = (330, 765) 45 | text = iata + " / " + icao 46 | draw.text((x, y), text, fill=black, font=font) 47 | #Distance 48 | (x, y) = (460, 765) 49 | text = str(round(distance_mi, 2)) + "mi / " + str(round(distance_km, 2)) + "km away" 50 | draw.text((x, y), text, fill=black, font=font) 51 | #Full name 52 | (x, y) = (330, 783) 53 | MAX_WIDTH = 325 54 | if font.getsize(airport['name'])[0] <= MAX_WIDTH: 55 | text = airport['name'] 56 | else: 57 | text = "" 58 | for char in airport['name']: 59 | if font.getsize(text)[0] >= (MAX_WIDTH - 10): 60 | text += "..." 61 | break 62 | else: 63 | text += char 64 | 65 | 66 | draw.text((x, y), text, fill=black, font=mini_font) 67 | image.show() 68 | # save the edited image 69 | image.save(filename) -------------------------------------------------------------------------------- /defADSBX.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | import configparser 4 | from datetime import datetime 5 | from http.client import IncompleteRead 6 | import http.client as http 7 | import urllib3 8 | import socket 9 | main_config = configparser.ConfigParser() 10 | main_config.read('./configs/mainconf.ini') 11 | api_version = main_config.get('ADSBX', 'API_VERSION') 12 | 13 | def pull(url, headers): 14 | try: 15 | response = requests.get(url, headers = headers, timeout=30) 16 | print ("HTTP Status Code:", response.status_code) 17 | response.raise_for_status() 18 | except (requests.HTTPError, ConnectionError, requests.Timeout, urllib3.exceptions.ConnectionError) as error_message: 19 | print("Basic Connection Error") 20 | print(error_message) 21 | response = None 22 | except (requests.RequestException, IncompleteRead, ValueError, socket.timeout, socket.gaierror) as error_message: 23 | print("Connection Error") 24 | print(error_message) 25 | response = None 26 | except Exception as error_message: 27 | print("Connection Error uncaught, basic exception for all") 28 | print(error_message) 29 | response = None 30 | return response 31 | 32 | def pull_adsbx(planes): 33 | api_version = int(main_config.get('ADSBX', 'API_VERSION')) 34 | if api_version not in [1, 2]: 35 | raise ValueError("Bad ADSBX API Version") 36 | if main_config.getboolean('ADSBX', 'ENABLE_PROXY') is False: 37 | if api_version == 1: 38 | if len(planes) > 1: 39 | url = "https://adsbexchange.com/api/aircraft/json/" 40 | elif len(planes) == 1: 41 | url = "https://adsbexchange.com/api/aircraft/icao/" + str(list(planes.keys())[0]) + "/" 42 | elif api_version == 2: 43 | url = "https://adsbexchange.com/api/aircraft/v2/all" 44 | else: 45 | if main_config.has_option('ADSBX', 'PROXY_HOST'): 46 | if api_version == 1: 47 | url = main_config.get('ADSBX', 'PROXY_HOST') + "/api/aircraft/json/all" 48 | if api_version == 2: 49 | url = main_config.get('ADSBX', 'PROXY_HOST') + "/api/aircraft/v2/all" 50 | else: 51 | raise ValueError("Proxy enabled but no host") 52 | headers = { 53 | 'api-auth': main_config.get('ADSBX', 'API_KEY'), 54 | 'Accept-Encoding': 'gzip' 55 | } 56 | response = pull(url, headers) 57 | if response is not None: 58 | try: 59 | data = json.loads(response.text) 60 | except (json.decoder.JSONDecodeError, ValueError) as error_message: 61 | print("Error with JSON") 62 | print(error_message) 63 | data = None 64 | except TypeError as error_message: 65 | print("Type Error", error_message) 66 | data = None 67 | else: 68 | if "msg" in data.keys() and data['msg'] != "No error": 69 | raise ValueError("Error from ADSBX: msg = ", data['msg']) 70 | if "ctime" in data.keys(): 71 | data_ctime = float(data['ctime']) / 1000.0 72 | print("Data ctime:",datetime.utcfromtimestamp(data_ctime)) 73 | if "now" in data.keys(): 74 | data_now = float(data['now']) / 1000.0 75 | print("Data now time:",datetime.utcfromtimestamp(data_now)) 76 | print("Current UTC:", datetime.utcnow()) 77 | else: 78 | data = None 79 | return data 80 | 81 | def pull_date_ras(date): 82 | url = f"https://globe.adsbexchange.com/globe_history/{date}/acas/acas.json" 83 | headers = { 84 | 'Accept-Encoding': 'gzip' 85 | } 86 | response = pull(url, headers) 87 | if response is not None: 88 | data = response.text.splitlines() 89 | else: 90 | data = None 91 | return data -------------------------------------------------------------------------------- /defSS.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from webdriver_manager.chrome import ChromeDriverManager 3 | import time 4 | from selenium.webdriver.support.ui import WebDriverWait 5 | from selenium.webdriver.common.by import By 6 | def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_track_labels=False): 7 | chrome_options = webdriver.ChromeOptions() 8 | chrome_options.headless = True 9 | chrome_options.add_argument('window-size=800,800') 10 | chrome_options.add_argument('ignore-certificate-errors') 11 | chrome_options.add_argument("--enable-logging --v=1") 12 | import os 13 | import platform 14 | if platform.system() == "Linux" and os.geteuid()==0: 15 | chrome_options.add_argument('--no-sandbox') # required when running as root user. otherwise you would get no sandbox errors. 16 | browser = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options) 17 | url = f"https://globe.adsbexchange.com/?{url_params}" 18 | browser.set_page_load_timeout(80) 19 | browser.get(url) 20 | remove_id_elements = ["show_trace", "credits", 'infoblock_close', 'selected_photo_link', "history_collapse"] 21 | for element in remove_id_elements: 22 | try: 23 | element = browser.find_element_by_id(element) 24 | browser.execute_script("""var element = arguments[0]; element.parentNode.removeChild(element); """, element) 25 | except: 26 | print("issue removing", element, "from map") 27 | #Remove watermark on data 28 | try: 29 | browser.execute_script("document.getElementById('selected_infoblock').className = 'none';") 30 | except: 31 | print("Couldn't remove watermark from map") 32 | #Disable slidebar 33 | try: 34 | browser.execute_script("$('#infoblock-container').css('overflow', 'hidden');") 35 | except: 36 | print("Couldn't disable sidebar on map") 37 | #Remove share 38 | try: 39 | element = browser.find_element_by_xpath("//*[contains(text(), 'Share')]") 40 | browser.execute_script("""var element = arguments[0]; element.parentNode.removeChild(element); """, element) 41 | except: 42 | print("Couldn't remove share button from map") 43 | #browser.execute_script("toggleFollow()") 44 | if enable_labels: 45 | browser.find_element_by_tag_name('body').send_keys('l') 46 | if enable_track_labels: 47 | browser.find_element_by_tag_name('body').send_keys('k') 48 | WebDriverWait(browser, 40).until(lambda d: d.execute_script("return jQuery.active == 0")) 49 | try: 50 | photo_box = browser.find_element_by_id("silhouette") 51 | except: 52 | pass 53 | else: 54 | import requests, json 55 | photo_list = json.loads(requests.get("https://raw.githubusercontent.com/Jxck-S/aircraft-photos/main/photo-list.json").text) 56 | if "icao" in url_params: 57 | import re 58 | 59 | icao = re.search('icao=(.+?)&', url_params).group(1).lower() 60 | print(icao) 61 | if icao in photo_list.keys(): 62 | browser.execute_script("arguments[0].id = 'airplanePhoto';", photo_box) 63 | browser.execute_script(f"arguments[0].src = 'https://raw.githubusercontent.com/Jxck-S/aircraft-photos/main/images/{photo_list[icao]['reg']}.jpg';", photo_box) 64 | copyright = browser.find_element_by_id("copyrightInfo") 65 | browser.execute_script("arguments[0].id = 'copyrightInfoFreeze';", copyright) 66 | browser.execute_script("$('#copyrightInfoFreeze').css('font-size', '12px');") 67 | browser.execute_script(f"arguments[0].appendChild(document.createTextNode('Image © {photo_list[icao]['photographer']}'))", copyright) 68 | 69 | time.sleep(5) 70 | browser.save_screenshot(file_path) 71 | browser.quit() 72 | def generate_adsbx_screenshot_time_params(timestamp): 73 | from datetime import datetime 74 | from datetime import timedelta 75 | timestamp_dt = datetime.utcfromtimestamp(timestamp) 76 | print(timestamp_dt) 77 | start_time = timestamp_dt - timedelta(minutes=1) 78 | time_params = "&showTrace=" + timestamp_dt.strftime("%Y-%m-%d") + "&startTime=" + start_time.strftime("%H:%M:%S") + "&endTime=" + timestamp_dt.strftime("%H:%M:%S") 79 | return time_params -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # plane-notify 2 | 3 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/c4e1d839eec3468cadfe351d64dc1ac4)](https://app.codacy.com/manual/Jxck-S/plane-notify?utm_source=github.com&utm_medium=referral&utm_content=Jxck-S/plane-notify&utm_campaign=Badge_Grade_Settings) 4 | [![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/) 5 | 6 | Notify if configured planes have taken off or landed using Python with OpenSky(free) or ADS-B Exchange Data(paid but much better), outputs location of takeoff location of landing and takeoff by reverse lookup of coordinates. 7 | 8 | ### Discord Output Example 9 | 10 | ![Discord Output Example](./ExImages/DiscordEX.png?raw=true) 11 | 12 | #### More examples in the ExImages folder 13 | 14 | [ExImages](./ExImages) 15 | 16 | ### Background 17 | 18 | I made this program so I could track Elon Musk's Jet and share with others of his whereabouts on Twitter. [![Twitter Follow](https://img.shields.io/twitter/follow/ElonJet.svg?style=social)](https://twitter.com/ElonJet) I have now Expanded and run multiple accounts for multiple planes, a list of the accounts here [plane-notify Twitter List](https://twitter.com/i/lists/1307414615316467715) 19 | 20 | ### Contributing 21 | 22 | Im open to any help or suggestions, I realize theirs much better ways im sure to do alot of my methods, im only a noob. I'll accept pull requests. If you'd like to discuss join 23 | 24 | ### [Algorithm](PseudoCode.md) 25 | 26 | ## Setup / Install 27 | 28 | ### Make sure Python/PIP is installed 29 | 30 | ```bash 31 | apt update 32 | apt install python3 33 | apt install python3-pip 34 | ``` 35 | 36 | ### Install Pipenv and Dependencies 37 | 38 | ```bash 39 | pip install pipenv 40 | pipenv install 41 | ``` 42 | 43 | ### Install Selenium / ChromeDriver or setup Google Static Maps 44 | 45 | Selenium/ChromeDriver is used to take a screenshot of the plane on globe.adsbexchange.com. Or use Google Static Maps, which can cost money if over used(No tutorial use to get to a key). 46 | 47 | #### Chromium 48 | 49 | ```bash 50 | sudo apt-get install chromium 51 | ``` 52 | These output methods once installed can be configured in planes config you create, using the example plane1.ini 53 | 54 | ### Install Screen to run in the background 55 | 56 | ```bash 57 | apt install screen 58 | ``` 59 | 60 | ### Download / Clone 61 | 62 | ```bash 63 | apt install git 64 | git clone -b multi --single-branch https://github.com/Jxck-S/plane-notify.git 65 | cd plane-notify 66 | ``` 67 | 68 | ### Configure main config file with keys and URLs (mainconf.ini) in configs directory 69 | 70 | - edit them with nano or vi on the running machine or on your pc and transfer the config to where you will be running the bot 71 | - Pick between OpenSky and ADS-B Exchange 72 | - The OpenSky API is free for everyone but the data is not as good as ADS-B Exchange. The ADS-B Exchange API is not free and this program will not work for the Rapid API from ADS-B Exchange. It only works with the API that they give when you have a partnership with ADS-B Exchange. It is not cheap to get the ADS-B Exchange full API, Don't contact them unless your ready to pay. 73 | - If you'd like to add support for ADS-B Exchanges RapidAPI feel free to work on it, and submit a merge request. 74 | - If you've setup multiple planes and want to use ADSB Exchange as your source you must have /all endpoint access to their API or it won't work. 75 | - Pick the correct api version for ADS-B Exchange. 76 | - Proxy is if your running multiple programs that use the ADSB Exchange, setup the proxy from lemonodor so you don't abuse the ADSB Exchange API, otherwise leave enable false. 77 | - When using OpenSky theres more bugs because I mainly use ADS-B Exchange and work less on the OpenSky Implementation. 78 | 79 | ### Configure individual planes 80 | 81 | - an example file is given (plane1.ini) plane config files should be in the configs directory, the program looks for any file in that folder with a .ini extension. 82 | - each plane should have its own config 83 | 84 | ### Enter and create new Screen Session 85 | 86 | ```bash 87 | screen -R 88 | ``` 89 | 90 | ### Start Program 91 | 92 | ```bash 93 | pipenv run python __main__ 94 | ``` 95 | 96 | ## Using with Docker 97 | 98 | Install [docker from their website](https://docs.docker.com/get-docker/). Run the following command from the root of the project. 99 | 100 | ```bash 101 | docker-compose up -d 102 | ``` 103 | 104 | After running this command, dut to the `-d` flag the container will be running in the background. To see the logs of the docker 105 | 106 | ### TODO 107 | 108 | - General Cleanup 109 | - Restructure project to make it proper currently random files because I didn't know how to properly structure a project before. (in progress) 110 | - Add proper logging and service to run the program and remove excessive printing. 111 | - Better single config YAML, or DB maybe 112 | 113 | ### [More Refrences/Documentation](Refrences.md) 114 | -------------------------------------------------------------------------------- /__main__.py: -------------------------------------------------------------------------------- 1 | import configparser 2 | import time 3 | from colorama import Fore, Back, Style 4 | import platform 5 | import traceback 6 | if platform.system() == "Windows": 7 | from colorama import init 8 | init(convert=True) 9 | from planeClass import Plane 10 | from datetime import datetime 11 | import pytz 12 | import os 13 | import signal 14 | abspath = os.path.abspath(__file__) 15 | dname = os.path.dirname(abspath) 16 | os.chdir(dname) 17 | import sys 18 | sys.path.extend([os.getcwd()]) 19 | #Dependency Handling 20 | if not os.path.isdir("./dependencies/"): 21 | os.mkdir("./dependencies/") 22 | required_files = [("Roboto-Regular.ttf", 'https://github.com/googlefonts/roboto/blob/main/src/hinted/Roboto-Regular.ttf?raw=true'), ('airports.csv', 'https://ourairports.com/data/airports.csv'), ('regions.csv', 'https://ourairports.com/data/regions.csv'), ('ADSBX_Logo.png', "https://www.adsbexchange.com/wp-content/uploads/cropped-Stealth.png"), ('Mictronics_db.zip', "https://www.mictronics.de/aircraft-database/indexedDB.php")] 23 | for file in required_files: 24 | file_name = file[0] 25 | url = file[1] 26 | if not os.path.isfile("./dependencies/" + file_name): 27 | print(file_name, "does not exist downloading now") 28 | try: 29 | import requests 30 | file_content = requests.get(url) 31 | 32 | open(("./dependencies/" + file_name), 'wb').write(file_content.content) 33 | except Exception as e: 34 | raise e("Error getting", file_name, "from", url) 35 | else: 36 | print("Successfully got", file_name) 37 | else: 38 | print("Already have", file_name, "continuing") 39 | if os.path.isfile("./dependencies/" + required_files[4][0]) and not os.path.isfile("./dependencies/aircrafts.json"): 40 | print("Extracting Mictronics DB") 41 | from zipfile import ZipFile 42 | with ZipFile("./dependencies/" + required_files[4][0], 'r') as mictronics_db: 43 | mictronics_db.extractall("./dependencies/") 44 | 45 | main_config = configparser.ConfigParser() 46 | print(os.getcwd()) 47 | main_config.read('./configs/mainconf.ini') 48 | source = main_config.get('DATA', 'SOURCE') 49 | if main_config.getboolean('DISCORD', 'ENABLE'): 50 | from defDiscord import sendDis 51 | sendDis("Started", main_config) 52 | def service_exit(signum, frame): 53 | if main_config.getboolean('DISCORD', 'ENABLE'): 54 | from defDiscord import sendDis 55 | sendDis("Service Stop", main_config) 56 | raise SystemExit("Service Stop") 57 | signal.signal(signal.SIGTERM, service_exit) 58 | if os.path.isfile("lookup_route.py"): 59 | print("Route lookup is enabled") 60 | else: 61 | print("Route lookup is disabled") 62 | 63 | try: 64 | print("Source is set to", source) 65 | import sys 66 | #Setup plane objects from plane configs 67 | planes = {} 68 | print("Found the following configs") 69 | for dirpath, dirname, filename in os.walk("./configs"): 70 | for filename in [f for f in filename if f.endswith(".ini") and f != "mainconf.ini"]: 71 | if not "disabled" in dirpath: 72 | print(os.path.join(dirpath, filename)) 73 | plane_config = configparser.ConfigParser() 74 | plane_config.read((os.path.join(dirpath, filename))) 75 | #Creates a Key labeled the ICAO of the plane, with the value being a plane object 76 | planes[plane_config.get('DATA', 'ICAO').upper()] = Plane(plane_config.get('DATA', 'ICAO'), os.path.join(dirpath, filename), plane_config) 77 | 78 | running_Count = 0 79 | failed_count = 0 80 | try: 81 | tz = pytz.timezone(main_config.get('DATA', 'TZ')) 82 | except pytz.exceptions.UnknownTimeZoneError: 83 | tz = pytz.UTC 84 | last_ra_count = None 85 | while True: 86 | datetime_tz = datetime.now(tz) 87 | if datetime_tz.hour == 0 and datetime_tz.minute == 0: 88 | running_Count = 0 89 | running_Count +=1 90 | start_time = time.time() 91 | header = ("-------- " + str(running_Count) + " -------- " + str(datetime_tz.strftime("%I:%M:%S %p")) + " ---------------------------------------------------------------------------") 92 | print (Back.GREEN + Fore.BLACK + header[0:100] + Style.RESET_ALL) 93 | if source == "ADSBX": 94 | #ACAS data 95 | from defADSBX import pull_date_ras 96 | import ast 97 | today = datetime.utcnow() 98 | date = today.strftime("%Y/%m/%d") 99 | ras = pull_date_ras(date) 100 | sorted_ras = {} 101 | if ras is not None: 102 | #Testing RAs 103 | #if last_ra_count is not None: 104 | # with open('./testing/acastest.json') as f: 105 | # data = f.readlines() 106 | # ras += data 107 | ra_count = len(ras) 108 | if last_ra_count is not None and ra_count != last_ra_count: 109 | print(abs(ra_count - last_ra_count), "new Resolution Advisories") 110 | for ra_num, ra in enumerate(ras[last_ra_count:]): 111 | ra = ast.literal_eval(ra) 112 | if ra['hex'].upper() in planes.keys(): 113 | if ra['hex'].upper() not in sorted_ras.keys(): 114 | sorted_ras[ra['hex'].upper()] = [ra] 115 | else: 116 | sorted_ras[ra['hex'].upper()].append(ra) 117 | else: 118 | print("No new Resolution Advisories") 119 | last_ra_count = ra_count 120 | for key, obj in planes.items(): 121 | if sorted_ras != {} and key in sorted_ras.keys(): 122 | print(key, "has", len(sorted_ras[key]), "RAs") 123 | obj.check_new_ras(sorted_ras[key]) 124 | obj.expire_ra_types() 125 | #Normal API data 126 | api_version = int(main_config.get('ADSBX', 'API_VERSION')) 127 | if api_version == 2: 128 | icao_key = 'hex' 129 | elif api_version == 1: 130 | icao_key = 'icao' 131 | else: 132 | raise ValueError("Invalid API Version") 133 | from defADSBX import pull_adsbx 134 | data = pull_adsbx(planes) 135 | if data is not None: 136 | if data['ac'] is not None: 137 | data_indexed = {} 138 | for planeData in data['ac']: 139 | data_indexed[planeData[icao_key].upper()] = planeData 140 | for key, obj in planes.items(): 141 | try: 142 | if api_version == 1: 143 | obj.run_adsbx_v1(data_indexed[key.upper()]) 144 | elif api_version == 2: 145 | obj.run_adsbx_v2(data_indexed[key.upper()]) 146 | except KeyError: 147 | obj.run_empty() 148 | else: 149 | for obj in planes.values(): 150 | obj.run_empty() 151 | else: 152 | failed_count += 1 153 | elif source == "OPENS": 154 | from defOpenSky import pull_opensky 155 | planeData, failed = pull_opensky(planes) 156 | if failed == False: 157 | if planeData != None and planeData.states != []: 158 | # print(planeData.time) 159 | for key, obj in planes.items(): 160 | has_data = False 161 | for dataState in planeData.states: 162 | if (dataState.icao24).upper() == key: 163 | obj.run_opens(dataState) 164 | has_data = True 165 | break 166 | if has_data is False: 167 | obj.run_empty() 168 | else: 169 | for obj in planes.values(): 170 | obj.run_empty() 171 | elif failed: 172 | failed_count += 1 173 | if failed_count >= 10 and main_config.getboolean('DATA', 'FAILOVER'): 174 | if source == "OPENS": 175 | source = "ADSBX" 176 | elif source == "ADSBX": 177 | source = "OPENS" 178 | failed_count = 0 179 | if main_config.getboolean('DISCORD', 'ENABLE'): 180 | from defDiscord import sendDis 181 | sendDis(str("Failed over to " + source), main_config) 182 | elapsed_calc_time = time.time() - start_time 183 | datetime_tz = datetime.now(tz) 184 | footer = "-------- " + str(running_Count) + " -------- " + str(datetime_tz.strftime("%I:%M:%S %p")) + " ------------------------Elapsed Time- " + str(round(elapsed_calc_time, 3)) + " -------------------------------------" 185 | print (Back.GREEN + Fore.BLACK + footer[0:100] + Style.RESET_ALL) 186 | 187 | sleep_sec = 30 188 | for i in range(sleep_sec,0,-1): 189 | if i < 10: 190 | i = " " + str(i) 191 | sys.stdout.write("\r") 192 | sys.stdout.write(Back.RED + "Sleep {00000000}".format(i) + Style.RESET_ALL) 193 | sys.stdout.flush() 194 | time.sleep(1) 195 | sys.stdout.write(Back.RED + ('\x1b[1K\r' +"Slept for " +str(sleep_sec)) + Style.RESET_ALL) 196 | print() 197 | except KeyboardInterrupt as e: 198 | print(e) 199 | if main_config.getboolean('DISCORD', 'ENABLE'): 200 | from defDiscord import sendDis 201 | sendDis(str("Manual Exit: " + str(e)), main_config) 202 | except Exception as e: 203 | if main_config.getboolean('DISCORD', 'ENABLE'): 204 | try: 205 | os.remove('crash_latest.log') 206 | except OSError: 207 | pass 208 | import logging 209 | logging.basicConfig(filename='crash_latest.log', filemode='w', format='%(asctime)s - %(message)s') 210 | logging.Formatter.converter = time.gmtime 211 | logging.error(e) 212 | logging.error(str(traceback.format_exc())) 213 | from defDiscord import sendDis 214 | sendDis(str("Error Exiting: " + str(e) + "Failed on " + key), main_config, "crash_latest.log") 215 | raise e -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "5131229ab384051accd51e665cc63da8e2d08a651ad0c9df09041fca9f306977" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.9" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "certifi": { 20 | "hashes": [ 21 | "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", 22 | "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569" 23 | ], 24 | "version": "==2021.10.8" 25 | }, 26 | "charset-normalizer": { 27 | "hashes": [ 28 | "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd", 29 | "sha256:cb957888737fc0bbcd78e3df769addb41fd1ff8cf950dc9e7ad7793f1bf44455" 30 | ], 31 | "markers": "python_version >= '3'", 32 | "version": "==2.0.10" 33 | }, 34 | "colorama": { 35 | "hashes": [ 36 | "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", 37 | "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2" 38 | ], 39 | "index": "pypi", 40 | "version": "==0.4.4" 41 | }, 42 | "configparser": { 43 | "hashes": [ 44 | "sha256:1b35798fdf1713f1c3139016cfcbc461f09edbf099d1fb658d4b7479fcaa3daa", 45 | "sha256:e8b39238fb6f0153a069aa253d349467c3c4737934f253ef6abac5fe0eca1e5d" 46 | ], 47 | "markers": "python_version >= '3.6'", 48 | "version": "==5.2.0" 49 | }, 50 | "crayons": { 51 | "hashes": [ 52 | "sha256:bd33b7547800f2cfbd26b38431f9e64b487a7de74a947b0fafc89b45a601813f", 53 | "sha256:e73ad105c78935d71fe454dd4b85c5c437ba199294e7ffd3341842bc683654b1" 54 | ], 55 | "version": "==0.4.0" 56 | }, 57 | "discord-webhook": { 58 | "hashes": [ 59 | "sha256:17e475d8a52fe0bfa26b071925f55087600e9bb96e821b611dc463f4b4998c89", 60 | "sha256:f3d660df572caaa9c2621edd7e8634a70d6d8295ce9256c365838312457069a1" 61 | ], 62 | "index": "pypi", 63 | "version": "==0.14.0" 64 | }, 65 | "geographiclib": { 66 | "hashes": [ 67 | "sha256:8f441c527b0b8a26cd96c965565ff0513d1e4d9952b704bf449409e5015c77b7", 68 | "sha256:ac400d672b8954b0306bca890b088bb8ba2a757dc8133cca0b878f34b33b2740" 69 | ], 70 | "version": "==1.52" 71 | }, 72 | "geopy": { 73 | "hashes": [ 74 | "sha256:58b7edf526b8c32e33126570b5f4fcdfaa29d4416506064777ae8d84cd103fdd", 75 | "sha256:8f1f949082b964385de61fcc3a667a6a9a6e242beb1ae8972449f164b2ba0e89" 76 | ], 77 | "index": "pypi", 78 | "version": "==2.2.0" 79 | }, 80 | "idna": { 81 | "hashes": [ 82 | "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", 83 | "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d" 84 | ], 85 | "markers": "python_version >= '3'", 86 | "version": "==3.3" 87 | }, 88 | "oauthlib": { 89 | "hashes": [ 90 | "sha256:42bf6354c2ed8c6acb54d971fce6f88193d97297e18602a3a886603f9d7730cc", 91 | "sha256:8f0215fcc533dd8dd1bee6f4c412d4f0cd7297307d43ac61666389e3bc3198a3" 92 | ], 93 | "markers": "python_version >= '3.6'", 94 | "version": "==3.1.1" 95 | }, 96 | "opensky-api": { 97 | "editable": true, 98 | "git": "https://github.com/openskynetwork/opensky-api.git", 99 | "ref": "d576cf260affd99156e352528ea46817273512d7", 100 | "subdirectory": "python" 101 | }, 102 | "pillow": { 103 | "hashes": [ 104 | "sha256:03b27b197deb4ee400ed57d8d4e572d2d8d80f825b6634daf6e2c18c3c6ccfa6", 105 | "sha256:0b281fcadbb688607ea6ece7649c5d59d4bbd574e90db6cd030e9e85bde9fecc", 106 | "sha256:0ebd8b9137630a7bbbff8c4b31e774ff05bbb90f7911d93ea2c9371e41039b52", 107 | "sha256:113723312215b25c22df1fdf0e2da7a3b9c357a7d24a93ebbe80bfda4f37a8d4", 108 | "sha256:2d16b6196fb7a54aff6b5e3ecd00f7c0bab1b56eee39214b2b223a9d938c50af", 109 | "sha256:2fd8053e1f8ff1844419842fd474fc359676b2e2a2b66b11cc59f4fa0a301315", 110 | "sha256:31b265496e603985fad54d52d11970383e317d11e18e856971bdbb86af7242a4", 111 | "sha256:3586e12d874ce2f1bc875a3ffba98732ebb12e18fb6d97be482bd62b56803281", 112 | "sha256:47f5cf60bcb9fbc46011f75c9b45a8b5ad077ca352a78185bd3e7f1d294b98bb", 113 | "sha256:490e52e99224858f154975db61c060686df8a6b3f0212a678e5d2e2ce24675c9", 114 | "sha256:500d397ddf4bbf2ca42e198399ac13e7841956c72645513e8ddf243b31ad2128", 115 | "sha256:52abae4c96b5da630a8b4247de5428f593465291e5b239f3f843a911a3cf0105", 116 | "sha256:6579f9ba84a3d4f1807c4aab4be06f373017fc65fff43498885ac50a9b47a553", 117 | "sha256:68e06f8b2248f6dc8b899c3e7ecf02c9f413aab622f4d6190df53a78b93d97a5", 118 | "sha256:6c5439bfb35a89cac50e81c751317faea647b9a3ec11c039900cd6915831064d", 119 | "sha256:72c3110228944019e5f27232296c5923398496b28be42535e3b2dc7297b6e8b6", 120 | "sha256:72f649d93d4cc4d8cf79c91ebc25137c358718ad75f99e99e043325ea7d56100", 121 | "sha256:7aaf07085c756f6cb1c692ee0d5a86c531703b6e8c9cae581b31b562c16b98ce", 122 | "sha256:80fe92813d208ce8aa7d76da878bdc84b90809f79ccbad2a288e9bcbeac1d9bd", 123 | "sha256:95545137fc56ce8c10de646074d242001a112a92de169986abd8c88c27566a05", 124 | "sha256:97b6d21771da41497b81652d44191489296555b761684f82b7b544c49989110f", 125 | "sha256:98cb63ca63cb61f594511c06218ab4394bf80388b3d66cd61d0b1f63ee0ea69f", 126 | "sha256:9f3b4522148586d35e78313db4db0df4b759ddd7649ef70002b6c3767d0fdeb7", 127 | "sha256:a09a9d4ec2b7887f7a088bbaacfd5c07160e746e3d47ec5e8050ae3b2a229e9f", 128 | "sha256:b5050d681bcf5c9f2570b93bee5d3ec8ae4cf23158812f91ed57f7126df91762", 129 | "sha256:bb47a548cea95b86494a26c89d153fd31122ed65255db5dcbc421a2d28eb3379", 130 | "sha256:bc462d24500ba707e9cbdef436c16e5c8cbf29908278af053008d9f689f56dee", 131 | "sha256:c2067b3bb0781f14059b112c9da5a91c80a600a97915b4f48b37f197895dd925", 132 | "sha256:d154ed971a4cc04b93a6d5b47f37948d1f621f25de3e8fa0c26b2d44f24e3e8f", 133 | "sha256:d5dcea1387331c905405b09cdbfb34611050cc52c865d71f2362f354faee1e9f", 134 | "sha256:ee6e2963e92762923956fe5d3479b1fdc3b76c83f290aad131a2f98c3df0593e", 135 | "sha256:fd0e5062f11cb3e730450a7d9f323f4051b532781026395c4323b8ad055523c4" 136 | ], 137 | "index": "pypi", 138 | "version": "==9.0.0" 139 | }, 140 | "pushbullet.py": { 141 | "hashes": [ 142 | "sha256:38e3ce79843efaf839c8dc43485c0c7eedbe5825a8751751f13d041dd00c5a37", 143 | "sha256:917883e1af4a0c979ce46076b391e0243eb8fe0a81c086544bcfa10f53e5ae64" 144 | ], 145 | "index": "pypi", 146 | "version": "==0.12.0" 147 | }, 148 | "python-magic": { 149 | "hashes": [ 150 | "sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626", 151 | "sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf" 152 | ], 153 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", 154 | "version": "==0.4.24" 155 | }, 156 | "pytz": { 157 | "hashes": [ 158 | "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da", 159 | "sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798" 160 | ], 161 | "index": "pypi", 162 | "version": "==2021.1" 163 | }, 164 | "requests": { 165 | "hashes": [ 166 | "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61", 167 | "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d" 168 | ], 169 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", 170 | "version": "==2.27.1" 171 | }, 172 | "requests-oauthlib": { 173 | "hashes": [ 174 | "sha256:7f71572defaecd16372f9006f33c2ec8c077c3cfa6f5911a9a90202beb513f3d", 175 | "sha256:b4261601a71fd721a8bd6d7aa1cc1d6a8a93b4a9f5e96626f8e4d91e8beeaa6a", 176 | "sha256:fa6c47b933f01060936d87ae9327fead68768b69c6c9ea2109c48be30f2d4dbc" 177 | ], 178 | "version": "==1.3.0" 179 | }, 180 | "selenium": { 181 | "hashes": [ 182 | "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c", 183 | "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d" 184 | ], 185 | "index": "pypi", 186 | "version": "==3.141.0" 187 | }, 188 | "shapely": { 189 | "hashes": [ 190 | "sha256:052eb5b9ba756808a7825e8a8020fb146ec489dd5c919e7d139014775411e688", 191 | "sha256:1641724c1055459a7e2b8bbe47ba25bdc89554582e62aec23cb3f3ca25f9b129", 192 | "sha256:17df66e87d0fe0193910aeaa938c99f0b04f67b430edb8adae01e7be557b141b", 193 | "sha256:182716ffb500d114b5d1b75d7fd9d14b7d3414cef3c38c0490534cc9ce20981a", 194 | "sha256:2df5260d0f2983309776cb41bfa85c464ec07018d88c0ecfca23d40bfadae2f1", 195 | "sha256:35be1c5d869966569d3dfd4ec31832d7c780e9df760e1fe52131105685941891", 196 | "sha256:46da0ea527da9cf9503e66c18bab6981c5556859e518fe71578b47126e54ca93", 197 | "sha256:4c10f317e379cc404f8fc510cd9982d5d3e7ba13a9cfd39aa251d894c6366798", 198 | "sha256:4f3c59f6dbf86a9fc293546de492f5e07344e045f9333f3a753f2dda903c45d1", 199 | "sha256:60e5b2282619249dbe8dc5266d781cc7d7fb1b27fa49f8241f2167672ad26719", 200 | "sha256:617bf046a6861d7c6b44d2d9cb9e2311548638e684c2cd071d8945f24a926263", 201 | "sha256:6593026cd3f5daaea12bcc51ae5c979318070fefee210e7990cb8ac2364e79a1", 202 | "sha256:6871acba8fbe744efa4f9f34e726d070bfbf9bffb356a8f6d64557846324232b", 203 | "sha256:791477edb422692e7dc351c5ed6530eb0e949a31b45569946619a0d9cd5f53cb", 204 | "sha256:8e7659dd994792a0aad8fb80439f59055a21163e236faf2f9823beb63a380e19", 205 | "sha256:8f15b6ce67dcc05b61f19c689b60f3fe58550ba994290ff8332f711f5aaa9840", 206 | "sha256:90a3e2ae0d6d7d50ff2370ba168fbd416a53e7d8448410758c5d6a5920646c1d", 207 | "sha256:a3774516c8a83abfd1ddffb8b6ec1b0935d7fe6ea0ff5c31a18bfdae567b4eba", 208 | "sha256:a5c3a50d823c192f32615a2a6920e8c046b09e07a58eba220407335a9cd2e8ea", 209 | "sha256:b40cc7bb089ae4aa9ddba1db900b4cd1bce3925d2a4b5837b639e49de054784f", 210 | "sha256:da38ed3d65b8091447dc3717e5218cc336d20303b77b0634b261bc5c1aa2bae8", 211 | "sha256:de618e67b64a51a0768d26a9963ecd7d338a2cf6e9e7582d2385f88ad005b3d1", 212 | "sha256:e3afccf0437edc108eef1e2bb9cc4c7073e7705924eb4cd0bf7715cd1ef0ce1b" 213 | ], 214 | "index": "pypi", 215 | "version": "==1.7.1" 216 | }, 217 | "tabulate": { 218 | "hashes": [ 219 | "sha256:d7c013fe7abbc5e491394e10fa845f8f32fe54f8dc60c6622c6cf482d25d47e4", 220 | "sha256:eb1d13f25760052e8931f2ef80aaf6045a6cceb47514db8beab24cded16f13a7" 221 | ], 222 | "index": "pypi", 223 | "version": "==0.8.9" 224 | }, 225 | "tweepy": { 226 | "hashes": [ 227 | "sha256:b28d72073b794141ad1cfdc34cb52b83b14d6b34cd4c5ea9d47bb85159b656e8", 228 | "sha256:bd3af045bed9cd6a838c32a1344d48191096e5cb930012452f8397b12c89d785" 229 | ], 230 | "index": "pypi", 231 | "version": "==4.0.0" 232 | }, 233 | "urllib3": { 234 | "hashes": [ 235 | "sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed", 236 | "sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c" 237 | ], 238 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", 239 | "version": "==1.26.8" 240 | }, 241 | "webdriver-manager": { 242 | "hashes": [ 243 | "sha256:50a6e174106542f5335cacc387cec7ada26812babc1aeca61c208a1bab2ac2c5", 244 | "sha256:c6d81590aae6fc0fb10cf7dd20c8c1b9bb043501f9cf62c316a854a0de841e32" 245 | ], 246 | "index": "pypi", 247 | "version": "==3.4.2" 248 | }, 249 | "websocket-client": { 250 | "hashes": [ 251 | "sha256:1315816c0acc508997eb3ae03b9d3ff619c9d12d544c9a9b553704b1cc4f6af5", 252 | "sha256:2eed4cc58e4d65613ed6114af2f380f7910ff416fc8c46947f6e76b6815f56c0" 253 | ], 254 | "markers": "python_version >= '3.6'", 255 | "version": "==1.2.3" 256 | } 257 | }, 258 | "develop": {} 259 | } 260 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /planeClass.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta 2 | class Plane: 3 | import configparser 4 | main_config = configparser.ConfigParser() 5 | main_config.read('./configs/mainconf.ini') 6 | def __init__(self, icao, config_path, config): 7 | """Initializes a plane object from its config file and given icao.""" 8 | self.icao = icao.upper() 9 | self.callsign = None 10 | self.reg = None 11 | self.config = config 12 | self.conf_file_path = config_path 13 | self.alt_ft = None 14 | self.below_desired_ft = None 15 | self.last_below_desired_ft = None 16 | self.feeding = None 17 | self.last_feeding = None 18 | self.last_on_ground = None 19 | self.on_ground = None 20 | self.longitude = None 21 | self.latitude = None 22 | self.takeoff_time = None 23 | import tempfile 24 | self.map_file_name = f"{tempfile.gettempdir()}/{icao.upper()}_map.png" 25 | self.last_latitude = None 26 | self.last_longitude = None 27 | self.last_pos_datetime = None 28 | self.landing_plausible = False 29 | self.nav_modes = None 30 | self.last_nav_modes = None 31 | self.speed = None 32 | self.recent_ra_types = {} 33 | self.db_flags = None 34 | self.sel_nav_alt = None 35 | self.last_sel_alt = None 36 | self.squawk = None 37 | self.emergency_already_triggered = None 38 | self.last_emergency = None 39 | self.recheck_route_time = None 40 | self.known_to_airport = None 41 | self.track = None 42 | self.last_track = None 43 | self.circle_history = None 44 | if self.config.has_option('DATA', 'DATA_LOSS_MINS'): 45 | self.data_loss_mins = self.config.getint('DATA', 'DATA_LOSS_MINS') 46 | else: 47 | self.data_loss_mins = Plane.main_config.getint('DATA', 'DATA_LOSS_MINS') 48 | #Setup Tweepy 49 | if self.config.getboolean('TWITTER', 'ENABLE'): 50 | from defTweet import tweepysetup 51 | self.tweet_api = tweepysetup(self.config) 52 | #Setup PushBullet 53 | if self.config.getboolean('PUSHBULLET', 'ENABLE'): 54 | from pushbullet import Pushbullet 55 | self.pb = Pushbullet(self.config['PUSHBULLET']['API_KEY']) 56 | self.pb_channel = self.pb.get_channel(self.config.get('PUSHBULLET', 'CHANNEL_TAG')) 57 | def run_opens(self, ac_dict): 58 | #Parse OpenSky Vector 59 | from colorama import Fore, Back, Style 60 | self.printheader("head") 61 | #print (Fore.YELLOW + "OpenSky Sourced Data: ", ac_dict) 62 | try: 63 | self.__dict__.update({'icao' : ac_dict.icao24.upper(), 'callsign' : ac_dict.callsign, 'latitude' : ac_dict.latitude, 'longitude' : ac_dict.longitude, 'on_ground' : bool(ac_dict.on_ground), 'squawk' : ac_dict.squawk, 'track' : float(ac_dict.heading)}) 64 | if ac_dict.baro_altitude != None: 65 | self.alt_ft = round(float(ac_dict.baro_altitude) * 3.281) 66 | elif self.on_ground: 67 | self.alt_ft = 0 68 | from mictronics_parse import get_aircraft_reg_by_icao, get_type_code_by_icao 69 | self.reg = get_aircraft_reg_by_icao(self.icao) 70 | self.type = get_type_code_by_icao(self.icao) 71 | self.last_pos_datetime = datetime.fromtimestamp(ac_dict.time_position) 72 | except ValueError as e: 73 | print("Got data but some data is invalid!") 74 | print(e) 75 | self.printheader("foot") 76 | else: 77 | self.feeding = True 78 | self.run_check() 79 | def run_adsbx_v1(self, ac_dict): 80 | #Parse ADBSX V1 Vector 81 | from colorama import Fore, Back, Style 82 | self.printheader("head") 83 | #print (Fore.YELLOW +"ADSBX Sourced Data: ", ac_dict, Style.RESET_ALL) 84 | try: 85 | #postime is divided by 1000 to get seconds from milliseconds, from timestamp expects secs. 86 | self.__dict__.update({'icao' : ac_dict['icao'].upper(), 'callsign' : ac_dict['call'], 'reg' : ac_dict['reg'], 'latitude' : float(ac_dict['lat']), 'longitude' : float(ac_dict['lon']), 'alt_ft' : int(ac_dict['alt']), 'on_ground' : bool(int(ac_dict["gnd"])), 'squawk' : ac_dict['sqk'], 'track' : float(ac_dict["trak"])}) 87 | if self.on_ground: 88 | self.alt_ft = 0 89 | self.last_pos_datetime = datetime.fromtimestamp(int(ac_dict['postime'])/1000) 90 | except ValueError as e: 91 | 92 | print("Got data but some data is invalid!") 93 | print(e) 94 | print (Fore.YELLOW +"ADSBX Sourced Data: ", ac_dict, Style.RESET_ALL) 95 | self.printheader("foot") 96 | else: 97 | self.feeding = True 98 | self.run_check() 99 | 100 | def run_adsbx_v2(self, ac_dict): 101 | #Parse ADBSX V2 Vector 102 | from colorama import Fore, Back, Style 103 | self.printheader("head") 104 | print(ac_dict) 105 | try: 106 | self.__dict__.update({'icao' : ac_dict['hex'].upper(), 'latitude' : float(ac_dict['lat']), 'longitude' : float(ac_dict['lon']), 'speed': ac_dict['gs']}) 107 | if "r" in ac_dict: 108 | self.reg = ac_dict['r'] 109 | if "t" in ac_dict: 110 | self.type = ac_dict['t'] 111 | if ac_dict['alt_baro'] != "ground": 112 | self.alt_ft = int(ac_dict['alt_baro']) 113 | self.on_ground = False 114 | elif ac_dict['alt_baro'] == "ground": 115 | self.alt_ft = 0 116 | self.on_ground = True 117 | if ac_dict.get('flight') is not None: 118 | self.callsign = ac_dict.get('flight').strip() 119 | if ac_dict.get('dbFlags') is not None: 120 | self.db_flags = ac_dict['dbFlags'] 121 | if 'nav_modes' in ac_dict: 122 | self.nav_modes = ac_dict['nav_modes'] 123 | for idx, mode in enumerate(self.nav_modes): 124 | if mode.upper() in ['TCAS', 'LNAV', 'VNAV']: 125 | self.nav_modes[idx] = self.nav_modes[idx].upper() 126 | else: 127 | self.nav_modes[idx] = self.nav_modes[idx].capitalize() 128 | self.squawk = ac_dict.get('squawk') 129 | if "track" in ac_dict: 130 | self.track = ac_dict['track'] 131 | if "nav_altitude_fms" in ac_dict: 132 | self.sel_nav_alt = ac_dict['nav_altitude_fms'] 133 | elif "nav_altitude_mcp" in ac_dict: 134 | self.sel_nav_alt = ac_dict['nav_altitude_mcp'] 135 | else: 136 | self.sel_nav_alt = None 137 | 138 | #Create last seen timestamp from how long ago in secs a pos was rec 139 | self.last_pos_datetime = datetime.now() - timedelta(seconds= ac_dict["seen_pos"]) 140 | except (ValueError, KeyError) as e: 141 | 142 | print("Got data but some data is invalid!") 143 | print(e) 144 | print (Fore.YELLOW +"ADSBX Sourced Data: ", ac_dict, Style.RESET_ALL) 145 | self.printheader("foot") 146 | else: 147 | #Error Handling for bad data, sometimes it would seem to be ADSB Decode error 148 | if (not self.on_ground) and self.speed <= 10: 149 | print("Not running check, appears to be bad ADSB Decode") 150 | else: 151 | self.feeding = True 152 | self.run_check() 153 | def __str__(self): 154 | from colorama import Fore, Back, Style 155 | from tabulate import tabulate 156 | if self.last_pos_datetime is not None: 157 | time_since_contact = self.get_time_since(self.last_pos_datetime) 158 | output = [ 159 | [(Fore.CYAN + "ICAO" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + self.icao + Style.RESET_ALL)], 160 | [(Fore.CYAN + "Callsign" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + self.callsign + Style.RESET_ALL)] if self.callsign is not None else None, 161 | [(Fore.CYAN + "Reg" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + self.reg + Style.RESET_ALL)] if self.reg is not None else None, 162 | [(Fore.CYAN + "Squawk" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + self.squawk + Style.RESET_ALL)] if self.squawk is not None else None, 163 | [(Fore.CYAN + "Coordinates" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + str(self.latitude) + ", " + str(self.longitude) + Style.RESET_ALL)] if self.latitude is not None and self.longitude is not None else None, 164 | [(Fore.CYAN + "Last Contact" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + str(time_since_contact).split(".")[0]+ Style.RESET_ALL)] if self.last_pos_datetime is not None else None, 165 | [(Fore.CYAN + "On Ground" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + str(self.on_ground) + Style.RESET_ALL)] if self.on_ground is not None else None, 166 | [(Fore.CYAN + "Baro Altitude" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + str("{:,} ft".format(self.alt_ft)) + Style.RESET_ALL)] if self.alt_ft is not None else None, 167 | [(Fore.CYAN + "Nav Modes" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + ', '.join(self.nav_modes) + Style.RESET_ALL)] if "nav_modes" in self.__dict__ and self.nav_modes != None else None, 168 | [(Fore.CYAN + "Sel Alt Ft" + Style.RESET_ALL), (Fore.LIGHTGREEN_EX + str("{:,} ft".format(self.sel_nav_alt)) + Style.RESET_ALL)] if "sel_nav_alt" in self.__dict__ and self.sel_nav_alt is not None else None 169 | ] 170 | output = list(filter(None, output)) 171 | return tabulate(output, [], 'fancy_grid') 172 | def printheader(self, type): 173 | from colorama import Fore, Back, Style 174 | if type == "head": 175 | header = str("--------- " + self.conf_file_path + " ---------------------------- ICAO: " + self.icao + " ---------------------------------------") 176 | elif type == "foot": 177 | header = "----------------------------------------------------------------------------------------------------" 178 | print(Back.MAGENTA + header[0:100] + Style.RESET_ALL) 179 | def get_time_since(self, datetime_obj): 180 | if datetime_obj != None: 181 | time_since = datetime.now() - datetime_obj 182 | else: 183 | time_since = None 184 | return time_since 185 | def get_adsbx_map_overlays(self): 186 | if self.config.has_option('MAP', 'OVERLAYS'): 187 | overlays = self.config.get('MAP', 'OVERLAYS') 188 | else: 189 | overlays = "" 190 | return overlays 191 | def route_info(self): 192 | from lookup_route import lookup_route, clean_data 193 | def route_format(extra_route_info, type): 194 | from defAirport import get_airport_by_icao 195 | to_airport = get_airport_by_icao(self.known_to_airport) 196 | code = to_airport['iata_code'] if to_airport['iata_code'] != "" else to_airport['icao'] 197 | airport_text = f"{code}, {to_airport['name']}" 198 | if 'time_to' in extra_route_info.keys() and type != "divert": 199 | arrival_rel = "in ~" + extra_route_info['time_to'] 200 | else: 201 | arrival_rel = None 202 | if self.known_to_airport != self.nearest_from_airport: 203 | if type == "inital": 204 | header = "Going to" 205 | elif type == "change": 206 | header = "Now going to" 207 | elif type == "divert": 208 | header = "Now diverting to" 209 | area = f"{to_airport['municipality']}, {to_airport['region']}, {to_airport['iso_country']}" 210 | route_to = f"{header} {area} ({airport_text})" + (f" arriving {arrival_rel}" if arrival_rel is not None else "") 211 | else: 212 | if type == "inital": 213 | header = "Will be returning to" 214 | elif type == "change": 215 | header = "Now returning to" 216 | elif type == "divert": 217 | header = "Now diverting back to" 218 | route_to = f"{header} {airport_text}" + (f" {arrival_rel}" if arrival_rel is not None else "") 219 | return route_to 220 | if hasattr(self, "type"): 221 | extra_route_info = clean_data(lookup_route(self.reg, (self.latitude, self.longitude), self.type, self.alt_ft)) 222 | else: 223 | extra_route_info = None 224 | route_to = None 225 | if extra_route_info is None: 226 | pass 227 | elif extra_route_info is not None: 228 | #Diversion 229 | if "divert_icao" in extra_route_info.keys(): 230 | if self.known_to_airport != extra_route_info["divert_icao"]: 231 | self.known_to_airport = extra_route_info['divert_icao'] 232 | route_to = route_format(extra_route_info, "divert") 233 | #Destination 234 | elif "dest_icao" in extra_route_info.keys(): 235 | #Inital Destination Found 236 | if self.known_to_airport is None: 237 | self.known_to_airport = extra_route_info['dest_icao'] 238 | route_to = route_format(extra_route_info, "inital") 239 | #Destination Change 240 | elif self.known_to_airport != extra_route_info["dest_icao"]: 241 | self.known_to_airport = extra_route_info['dest_icao'] 242 | route_to = route_format(extra_route_info, "change") 243 | 244 | return route_to 245 | def run_empty(self): 246 | self.printheader("head") 247 | self.feeding = False 248 | self.run_check() 249 | def run_check(self): 250 | """Runs a check of a plane module to see if its landed or takenoff using plane data, and takes action if so.""" 251 | print(self) 252 | #Ability to Remove old Map 253 | import os 254 | from colorama import Fore, Style 255 | from tabulate import tabulate 256 | #Proprietary Route Lookup 257 | if os.path.isfile("lookup_route.py") and (self.db_flags is None or not self.db_flags & 1): 258 | from lookup_route import lookup_route 259 | ENABLE_ROUTE_LOOKUP = True 260 | else: 261 | ENABLE_ROUTE_LOOKUP = False 262 | if self.config.getboolean('DISCORD', 'ENABLE'): 263 | from defDiscord import sendDis 264 | if self.last_pos_datetime is not None: 265 | time_since_contact = self.get_time_since(self.last_pos_datetime) 266 | #Check if below desire ft 267 | desired_ft = 15000 268 | if self.alt_ft is None or self.alt_ft > desired_ft: 269 | self.below_desired_ft = False 270 | elif self.alt_ft < desired_ft: 271 | self.below_desired_ft = True 272 | #Check if tookoff 273 | if self.below_desired_ft and self.on_ground is False: 274 | if self.last_on_ground: 275 | self.tookoff = True 276 | trigger_type = "no longer on ground" 277 | type_header = "Took off from" 278 | elif self.last_feeding is False and self.feeding and self.landing_plausible == False: 279 | from defAirport import getClosestAirport 280 | nearest_airport_dict = getClosestAirport(self.latitude, self.longitude, self.config.get("AIRPORT", "TYPES")) 281 | if nearest_airport_dict['elevation_ft'] != "": 282 | alt_above_airport = (self.alt_ft - int(nearest_airport_dict['elevation_ft'])) 283 | print(f"AGL nearest airport: {alt_above_airport}") 284 | else: 285 | alt_above_airport = None 286 | if (alt_above_airport != None and alt_above_airport <= 10000) or self.alt_ft <= 15000: 287 | self.tookoff = True 288 | trigger_type = "data acquisition" 289 | type_header = "Took off near" 290 | else: 291 | self.tookoff = False 292 | else: 293 | self.tookoff = False 294 | 295 | #Check if Landed 296 | if self.on_ground and self.last_on_ground is False and self.last_below_desired_ft: 297 | self.landed = True 298 | trigger_type = "now on ground" 299 | type_header = "Landed in" 300 | self.landing_plausible = False 301 | #Set status for landing plausible 302 | elif self.below_desired_ft and self.last_feeding and self.feeding is False and self.last_on_ground is False: 303 | self.landing_plausible = True 304 | print("Near landing conditions, if contiuned data loss for configured time, and if under 10k AGL landing true") 305 | 306 | elif self.landing_plausible and self.feeding is False and time_since_contact.total_seconds() >= (self.data_loss_mins * 60): 307 | from defAirport import getClosestAirport 308 | nearest_airport_dict = getClosestAirport(self.latitude, self.longitude, self.config.get("AIRPORT", "TYPES")) 309 | if nearest_airport_dict['elevation_ft'] != "": 310 | alt_above_airport = (self.alt_ft - int(nearest_airport_dict['elevation_ft'])) 311 | print(f"AGL nearest airport: {alt_above_airport}") 312 | else: 313 | alt_above_airport = None 314 | if (alt_above_airport != None and alt_above_airport <= 10000) or self.alt_ft <= 15000: 315 | self.landing_plausible = False 316 | self.on_ground = None 317 | self.landed = True 318 | trigger_type = "data loss" 319 | type_header = "Landed near" 320 | else: 321 | print("Alt greater then 10k AGL") 322 | self.landing_plausible = False 323 | self.on_ground = None 324 | else: 325 | self.landed = False 326 | 327 | if self.landed: 328 | print ("Landed by", trigger_type) 329 | if self.tookoff: 330 | print("Tookoff by", trigger_type) 331 | #Find nearest airport, and location 332 | if self.landed or self.tookoff: 333 | from defAirport import getClosestAirport 334 | if "nearest_airport_dict" in globals(): 335 | pass #Airport already set 336 | elif trigger_type in ["now on ground", "data acquisition", "data loss"]: 337 | nearest_airport_dict = getClosestAirport(self.latitude, self.longitude, self.config.get("AIRPORT", "TYPES")) 338 | elif trigger_type == "no longer on ground": 339 | nearest_airport_dict = getClosestAirport(self.last_latitude, self.last_longitude, self.config.get("AIRPORT", "TYPES")) 340 | #Convert dictionary keys to sep variables 341 | country_code = nearest_airport_dict['iso_country'] 342 | state = nearest_airport_dict['region'].strip() 343 | municipality = nearest_airport_dict['municipality'].strip() 344 | if municipality == "" or state == "" or municipality == state: 345 | if municipality != "": 346 | area = municipality 347 | elif state != "": 348 | area = state 349 | else: 350 | area = "" 351 | else: 352 | area = f"{municipality}, {state}" 353 | location_string = (f"{area}, {country_code}") 354 | print (Fore.GREEN + "Country Code:", country_code, "State:", state, "Municipality:", municipality + Style.RESET_ALL) 355 | title_switch = { 356 | "reg": self.reg, 357 | "callsign": self.callsign, 358 | "icao": self.icao, 359 | } 360 | #Set Discord Title 361 | if self.config.getboolean('DISCORD', 'ENABLE'): 362 | self.dis_title = (title_switch.get(self.config.get('DISCORD', 'TITLE')) or "NA").strip() if self.config.get('DISCORD', 'TITLE') in title_switch.keys() else self.config.get('DISCORD', 'TITLE') 363 | #Set Twitter Title 364 | if self.config.getboolean('TWITTER', 'ENABLE'): 365 | self.twitter_title = (title_switch.get(self.config.get('TWITTER', 'TITLE')) or "NA") if self.config.get('TWITTER', 'TITLE') in title_switch.keys() else self.config.get('TWITTER', 'TITLE') 366 | #Takeoff and Land Notification 367 | if self.tookoff or self.landed: 368 | route_to = None 369 | if self.tookoff: 370 | self.takeoff_time = datetime.utcnow() 371 | landed_time_msg = None 372 | #Proprietary Route Lookup 373 | if ENABLE_ROUTE_LOOKUP: 374 | self.nearest_from_airport = nearest_airport_dict['icao'] 375 | route_to = self.route_info() 376 | if route_to is None: 377 | self.recheck_route_time = 1 378 | else: 379 | self.recheck_route_time = 10 380 | elif self.landed and self.takeoff_time != None: 381 | landed_time = datetime.utcnow() - self.takeoff_time 382 | if trigger_type == "data loss": 383 | landed_time -= timedelta(seconds=time_since_contact.total_seconds()) 384 | hours, remainder = divmod(landed_time.total_seconds(), 3600) 385 | minutes, seconds = divmod(remainder, 60) 386 | min_syntax = "Mins" if minutes > 1 else "Min" 387 | if hours > 0: 388 | hour_syntax = "Hours" if hours > 1 else "Hour" 389 | landed_time_msg = (f"Apx. flt. time {int(hours)} {hour_syntax}" + (f" : {int(minutes)} {min_syntax}. " if minutes > 0 else ".")) 390 | else: 391 | landed_time_msg = (f"Apx. flt. time {int(minutes)} {min_syntax}.") 392 | self.takeoff_time = None 393 | elif self.landed: 394 | landed_time_msg = None 395 | message = (f"{type_header} {location_string}.") + ("" if route_to is None else f" {route_to}.") + ((f" {landed_time_msg}") if landed_time_msg != None else "") 396 | print (message) 397 | #Google Map or tar1090 screenshot 398 | if self.config.get('MAP', 'OPTION') == "GOOGLESTATICMAP": 399 | from defMap import getMap 400 | getMap((municipality + ", " + state + ", " + country_code), self.map_file_name) 401 | elif self.config.get('MAP', 'OPTION') == "ADSBX": 402 | from defSS import get_adsbx_screenshot 403 | 404 | url_params = f"icao={self.icao}&zoom=9&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays=" + self.get_adsbx_map_overlays() 405 | get_adsbx_screenshot(self.map_file_name, url_params) 406 | from modify_image import append_airport 407 | append_airport(self.map_file_name, nearest_airport_dict) 408 | else: 409 | raise ValueError("Map option not set correctly in this planes conf") 410 | #Discord 411 | if self.config.getboolean('DISCORD', 'ENABLE'): 412 | dis_message = f"{self.dis_title} {message}".strip() 413 | role_id = self.config.get('DISCORD', 'ROLE_ID') if self.config.has_option('DISCORD', 'ROLE_ID') else None 414 | sendDis(dis_message, self.config, self.map_file_name, role_id = role_id) 415 | #PushBullet 416 | if self.config.getboolean('PUSHBULLET', 'ENABLE'): 417 | with open(self.map_file_name, "rb") as pic: 418 | map_data = self.pb.upload_file(pic, "Tookoff IMG" if self.tookoff else "Landed IMG") 419 | self.pb_channel.push_note(self.config.get('PUSHBULLET', 'TITLE'), message) 420 | self.pb_channel.push_file(**map_data) 421 | #Twitter 422 | if self.config.getboolean('TWITTER', 'ENABLE'): 423 | twitter_media_map_obj = self.tweet_api.media_upload(self.map_file_name) 424 | alt_text = f"Reg: {self.reg} On Ground: {str(self.on_ground)} Alt: {str(self.alt_ft)} Last Contact: {str(time_since_contact)} Trigger: {trigger_type}" 425 | self.tweet_api.create_media_metadata(media_id= twitter_media_map_obj.media_id, alt_text= alt_text) 426 | self.latest_tweet_id = self.tweet_api.update_status(status = ((self.twitter_title + " " + message).strip()), media_ids=[twitter_media_map_obj.media_id]).id 427 | os.remove(self.map_file_name) 428 | if self.landed: 429 | self.latest_tweet_id = None 430 | self.recheck_route_time = None 431 | self.known_to_airport = None 432 | self.nearest_from_airport = None 433 | #Recheck Proprietary Route Info. 434 | if self.takeoff_time is not None and self.recheck_route_time is not None and (datetime.utcnow() - self.takeoff_time).total_seconds() > 60 * self.recheck_route_time: 435 | self.recheck_route_time += 10 436 | route_to = self.route_info() 437 | if route_to != None: 438 | print(route_to) 439 | #Discord 440 | if self.config.getboolean('DISCORD', 'ENABLE'): 441 | dis_message = f"{self.dis_title} {route_to}".strip() 442 | role_id = self.config.get('DISCORD', 'ROLE_ID') if self.config.has_option('DISCORD', 'ROLE_ID') else None 443 | sendDis(dis_message, self.config, role_id = role_id) 444 | #Twitter 445 | if self.config.getboolean('TWITTER', 'ENABLE'): 446 | #tweet = self.tweet_api.user_timeline(count = 1)[0] 447 | self.latest_tweet_id = self.tweet_api.update_status(status = f"{self.twitter_title} {route_to}".strip(), in_reply_to_status_id = self.latest_tweet_id).id 448 | 449 | if self.circle_history is not None: 450 | #Expires traces for circles 451 | if self.circle_history["traces"] != []: 452 | for trace in self.circle_history["traces"]: 453 | if (datetime.now() - datetime.fromtimestamp(trace[0])).total_seconds() >= 20*60: 454 | print("Trace Expire, removed") 455 | self.circle_history["traces"].remove(trace) 456 | #Expire touchngo 457 | if "touchngo" in self.circle_history.keys() and (datetime.now() - datetime.fromtimestamp(self.circle_history['touchngo'])).total_seconds() >= 10*60: 458 | self.circle_history.pop("touchngo") 459 | if self.feeding: 460 | #Squawks 461 | emergency_squawks ={"7500" : "Hijacking", "7600" :"Radio Failure", "7700" : "General Emergency"} 462 | seen = datetime.now() - self.last_pos_datetime 463 | #Only run check if emergency data previously set 464 | if self.last_emergency is not None and not self.emergency_already_triggered: 465 | time_since_org_emer = datetime.now() - self.last_emergency[0] 466 | #Checks times to see x time and still same squawk 467 | if time_since_org_emer.total_seconds() >= 60 and self.last_emergency[1] == self.squawk and seen.total_seconds() <= 60: 468 | self.emergency_already_triggered = True 469 | squawk_message = (f"{self.dis_title} Squawking {self.last_emergency[1]} {emergency_squawks[self.squawk]}").strip() 470 | print(squawk_message) 471 | #Google Map or tar1090 screenshot 472 | if self.config.get('MAP', 'OPTION') == "GOOGLESTATICMAP": 473 | getMap((municipality + ", " + state + ", " + country_code), self.map_file_name) 474 | if self.config.get('MAP', 'OPTION') == "ADSBX": 475 | from defSS import get_adsbx_screenshot 476 | url_params = f"icao={self.icao}&zoom=9&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays=" + self.get_adsbx_map_overlays() 477 | get_adsbx_screenshot(self.map_file_name, url_params) 478 | if self.config.getboolean('DISCORD', 'ENABLE'): 479 | dis_message = (self.dis_title + " " + squawk_message) 480 | sendDis(dis_message, self.config, self.map_file_name) 481 | os.remove(self.map_file_name) 482 | #Realizes first time seeing emergency, stores time and type 483 | elif self.squawk in emergency_squawks.keys() and not self.emergency_already_triggered and not self.on_ground: 484 | print("Emergency", self.squawk, "detected storing code and time and waiting to trigger") 485 | self.last_emergency = (self.last_pos_datetime, self.squawk) 486 | elif self.squawk not in emergency_squawks.keys() and self.emergency_already_triggered: 487 | self.emergency_already_triggered = None 488 | 489 | #Nav Modes Notifications 490 | if self.nav_modes != None and self.last_nav_modes != None: 491 | for mode in self.nav_modes: 492 | if mode not in self.last_nav_modes: 493 | #Discord 494 | print(mode, "enabled") 495 | if self.config.getboolean('DISCORD', 'ENABLE'): 496 | dis_message = (self.dis_title + " " + mode + " mode enabled.") 497 | if mode == "Approach": 498 | from defSS import get_adsbx_screenshot 499 | url_params = f"icao={self.icao}&zoom=9&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays={self.get_adsbx_map_overlays()}" 500 | get_adsbx_screenshot(self.map_file_name, url_params) 501 | sendDis(dis_message, self.config, self.map_file_name) 502 | #elif mode in ["Althold", "VNAV", "LNAV"] and self.sel_nav_alt != None: 503 | # sendDis((dis_message + ", Sel Alt. " + str(self.sel_nav_alt) + ", Current Alt. " + str(self.alt_ft)), self.config) 504 | else: 505 | sendDis(dis_message, self.config) 506 | #Selected Altitude 507 | if self.sel_nav_alt is not None and self.last_sel_alt is not None and self.last_sel_alt != self.sel_nav_alt: 508 | #Discord 509 | print("Nav altitude is now", self.sel_nav_alt) 510 | if self.config.getboolean('DISCORD', 'ENABLE'): 511 | dis_message = (self.dis_title + " Sel. alt. " + str("{:,} ft".format(self.sel_nav_alt))) 512 | sendDis(dis_message,self.config) 513 | #Circling 514 | if self.last_track is not None: 515 | import time 516 | if self.circle_history is None: 517 | self.circle_history = {"traces" : [], "triggered" : False} 518 | #Add touchngo 519 | if self.on_ground or self.alt_ft <= 500: 520 | self.circle_history["touchngo"] = time.time() 521 | #Add a Trace 522 | if self.on_ground is False: 523 | from calculate_headings import calculate_deg_change 524 | track_change = calculate_deg_change(self.track, self.last_track) 525 | track_change = round(track_change, 3) 526 | self.circle_history["traces"].append((time.time(), self.latitude, self.longitude, track_change)) 527 | 528 | total_change = 0 529 | coords = [] 530 | for trace in self.circle_history["traces"]: 531 | total_change += float(trace[3]) 532 | coords.append((float(trace[1]), float(trace[2]))) 533 | 534 | print("Total Bearing Change", round(total_change, 3)) 535 | #Check Centroid when Bearing change meets req 536 | if abs(total_change) >= 720 and self.circle_history['triggered'] is False: 537 | print("Circling Bearing Change Met") 538 | from shapely.geometry import MultiPoint 539 | from geopy.distance import geodesic 540 | aircraft_coords = (self.latitude, self.longitude) 541 | points = MultiPoint(coords) 542 | cent = (points.centroid) #True centroid, not necessarily an existing point 543 | #rp = (points.representative_point()) #A represenative point, not centroid, 544 | print(cent) 545 | #print(rp) 546 | distance_to_centroid = geodesic(aircraft_coords, cent.coords).mi 547 | print(f"Distance to centroid of circling coordinates {distance_to_centroid} miles") 548 | if distance_to_centroid <= 15: 549 | print("Within 15 miles of centroid, CIRCLING") 550 | from defAirport import getClosestAirport 551 | nearest_airport_dict = getClosestAirport(self.latitude, self.longitude, ["small_airport", "medium_airport", "large_airport"]) 552 | from calculate_headings import calculate_from_bearing, calculate_cardinal 553 | from_bearing = calculate_from_bearing((float(nearest_airport_dict['latitude_deg']), float(nearest_airport_dict['longitude_deg'])), (self.latitude, self.longitude)) 554 | cardinal = calculate_cardinal(from_bearing) 555 | from defSS import get_adsbx_screenshot 556 | url_params = f"icao={self.icao}&zoom=10&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays={self.get_adsbx_map_overlays()}" 557 | get_adsbx_screenshot(self.map_file_name, url_params) 558 | if nearest_airport_dict['distance_mi'] < 3: 559 | if "touchngo" in self.circle_history.keys(): 560 | message = f"Doing touch and goes at {nearest_airport_dict['icao']}" 561 | else: 562 | message = f"Circling over {nearest_airport_dict['icao']} at {self.alt_ft}ft" 563 | else: 564 | message = f"Circling {round(nearest_airport_dict['distance_mi'], 2)}mi {cardinal} of {nearest_airport_dict['icao']}, {nearest_airport_dict['name']} at {self.alt_ft}ft" 565 | print(message) 566 | if self.config.getboolean('DISCORD', 'ENABLE'): 567 | role_id = self.config.get('DISCORD', 'ROLE_ID') if self.config.has_option('DISCORD', 'ROLE_ID') else None 568 | sendDis(message, self.config, self.map_file_name, role_id) 569 | if self.config.getboolean('TWITTER', 'ENABLE'): 570 | twitter_media_map_obj = self.tweet_api.media_upload(self.map_file_name) 571 | alt_text = f"Distance to centroid: {distance_to_centroid}, Total change: {total_change}" 572 | self.tweet_api.create_media_metadata(media_id= twitter_media_map_obj.media_id, alt_text= alt_text) 573 | tweet = self.tweet_api.user_timeline(count = 1)[0] 574 | self.latest_tweet_id = self.tweet_api.update_status(status = f"{self.twitter_title} {message}".strip(), in_reply_to_status_id = self.latest_tweet_id, media_ids=[twitter_media_map_obj.media_id]).id 575 | 576 | self.circle_history['triggered'] = True 577 | elif abs(total_change) <= 360 and self.circle_history["triggered"]: 578 | print("No Longer Circling, trigger cleared") 579 | self.circle_history['triggered'] = False 580 | # #Power Up 581 | # if self.last_feeding == False and self.speed == 0 and self.on_ground: 582 | # if self.config.getboolean('DISCORD', 'ENABLE'): 583 | # dis_message = (self.dis_title + "Powered Up").strip() 584 | # sendDis(dis_message, self.config) 585 | 586 | 587 | #Set Variables to compare to next check 588 | self.last_track = self.track 589 | self.last_feeding = self.feeding 590 | self.last_on_ground = self.on_ground 591 | self.last_below_desired_ft = self.below_desired_ft 592 | self.last_longitude = self.longitude 593 | self.last_latitude = self.latitude 594 | self.last_nav_modes = self.nav_modes 595 | self.last_sel_alt = self.sel_nav_alt 596 | 597 | 598 | if self.takeoff_time != None: 599 | elapsed_time = datetime.utcnow() - self.takeoff_time 600 | hours, remainder = divmod(elapsed_time.total_seconds(), 3600) 601 | minutes, seconds = divmod(remainder, 60) 602 | print((f"Time Since Take off {int(hours)} Hours : {int(minutes)} Mins : {int(seconds)} Secs")) 603 | self.printheader("foot") 604 | def check_new_ras(self, ras): 605 | for ra in ras: 606 | if self.recent_ra_types == {} or ra['acas_ra']['advisory'] not in self.recent_ra_types.keys(): 607 | self.recent_ra_types[ra['acas_ra']['advisory']] = ra['acas_ra']['unix_timestamp'] 608 | ra_message = f"TCAS Resolution Advisory: {ra['acas_ra']['advisory']}" 609 | if ra['acas_ra']['advisory_complement'] != "": 610 | ra_message += f", {ra['acas_ra']['advisory_complement']}" 611 | if bool(int(ra['acas_ra']['MTE'])): 612 | ra_message += ", Multi threat" 613 | from defSS import get_adsbx_screenshot, generate_adsbx_screenshot_time_params 614 | url_params = f"&lat={ra['lat']}&lon={ra['lon']}&zoom=11&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays={self.get_adsbx_map_overlays()}" 615 | if "threat_id_hex" in ra['acas_ra'].keys(): 616 | from mictronics_parse import get_aircraft_reg_by_icao 617 | threat_reg = get_aircraft_reg_by_icao(ra['acas_ra']['threat_id_hex']) 618 | threat_id = threat_reg if threat_reg is not None else "ICAO: " + ra['acas_ra']['threat_id_hex'] 619 | ra_message += f", invader: {threat_id}" 620 | url_params += generate_adsbx_screenshot_time_params(ra['acas_ra']['unix_timestamp']) + f"&icao={ra['acas_ra']['threat_id_hex']},{self.icao.lower()}×tamp={ra['acas_ra']['unix_timestamp']}" 621 | else: 622 | url_params += f"&icao={self.icao.lower()}&noIsolation" 623 | print(url_params) 624 | get_adsbx_screenshot(self.map_file_name, url_params, True, True) 625 | 626 | if self.config.getboolean('DISCORD', 'ENABLE'): 627 | from defDiscord import sendDis 628 | dis_message = f"{self.dis_title} {ra_message}" 629 | role_id = self.config.get('DISCORD', 'ROLE_ID') if self.config.has_option('DISCORD', 'ROLE_ID') else None 630 | sendDis(dis_message, self.config, self.map_file_name, role_id = role_id) 631 | #if twitter 632 | def expire_ra_types(self): 633 | if self.recent_ra_types != {}: 634 | for ra_type, postime in self.recent_ra_types.copy().items(): 635 | timestamp = datetime.fromtimestamp(postime) 636 | time_since_ra = datetime.now() - timestamp 637 | print(time_since_ra) 638 | if time_since_ra.seconds >= 600: 639 | print(ra_type) 640 | self.recent_ra_types.pop(ra_type) --------------------------------------------------------------------------------