Improved acft-db
I ran a script to populate all of the cruise speeds of the aircraft in the acft-db config file, in order to be able to spawn them during teacher/student sessions. Here is the script in case needed:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as BraveService
from selenium.webdriver.common.by import By
from selenium.common.exceptions import *
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
from ext.data import load_aircraft_db
from base.db import acft_db
driver = *your Selenium web driver*
# Call ATC-pie's method to load the database.
load_aircraft_db()
with open("OUTPUT/acft-db-auto", "x") as file:
# Write an explanation line as comment
file.write("# ICAO designator\t|\tX-plane category\t|\tWTC\t|\tCruise speed\n")
for desig, v in acft_db.items():
# First try on Eurocontrol's Performance Database website
driver.get(f"https://contentzone.eurocontrol.int/aircraftperformance/default.aspx?ICAOFilter={desig}")
try:
cruise_speed = driver.find_element(By.XPATH, f"//*[@id='div2TogglePerf{desig}']/div[4]/p[4]").text\
.replace("TAS ", "").replace(" kt", "") # Need to replace "TAS" and "kt" to get just digits
name = driver.find_element(By.XPATH, f"//*[@id='{desig}']/div[2]/p/a").text.replace("\n", " ")
file.write(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed}\t#\t{name}\n")
print(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed}\t#\t{name}\n")
except NoSuchElementException:
# If the aircraft is not found on Eurocontrol, try on doc8643.com, less "official", but still well-made
try:
driver.get(f"https://doc8643.com/aircraft/{desig}")
cruise_speed = driver.find_element(By.XPATH, "/html/body/div[2]/div/div[1]/div[3]/div[13]/div[2]").text
name = driver.find_element(By.XPATH, f"/html/body/div[2]/div/div[2]/div/div/div").text
file.write(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed if not cruise_speed == '' else '-'}\t#\t{name}\n")
print(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed if not cruise_speed == '' else '-'}\t#\t{name}\n")
except NoSuchElementException:
continue
except UnicodeEncodeError:
# Catch odd characters that raise exceptions when encoding in Unicode
i = -1
for c in name:
i += 1
if not c.isascii():
name = name.replace(name[i], "")
# Try writing on the file once again
file.write(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed if not cruise_speed == '' else '-'}\t#\t{name}\n")
print(f"{desig}\t{v[0]}\t{v[1]}\t{cruise_speed if not cruise_speed == '' else '-'}\t#\t{name}\n")
continue
driver.close()
The sources I used for the cruise speeds are Eurocontrol's Performance Database, which is somewhat official, just not to be used for operational purposes, and doc8643.com, less official, but well made nonetheless.