Browse Source

Selenium 4.3.0 Fixes

-Replace deprecated functions
-Uses Tar1090 LimitUpdates parameter for screenshots
-Pip updates
pull/68/head
Jxck-S 3 years ago
parent
commit
d71242fa2f
  1. 805
      Pipfile.lock
  2. 28
      defSS.py
  3. 10
      planeClass.py

805
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

28
defSS.py

@ -27,7 +27,7 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
remove_id_elements = ["show_trace", "credits", 'infoblock_close', 'selected_photo_link', "history_collapse"]
for element in remove_id_elements:
try:
element = browser.find_element_by_id(element)
element = browser.find_element(By.ID, element)
browser.execute_script("""var element = arguments[0]; element.parentNode.removeChild(element); """, element)
except:
print("issue removing", element, "from map")
@ -43,7 +43,7 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
print("Couldn't disable sidebar on map")
#Remove Google Ads
try:
element = browser.find_element_by_xpath("//*[contains(@id, 'FIOnDemandWrapper_')]")
element = browser.find_element(By.XPATH, "//*[contains(@id, 'FIOnDemandWrapper_')]")
browser.execute_script("""var element = arguments[0]; element.parentNode.removeChild(element); """, element)
except:
print("Couldn't remove Google Ads")
@ -55,29 +55,29 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
# print("Couldn't remove share button from map", e)
#browser.execute_script("toggleFollow()")
if enable_labels:
browser.find_element_by_tag_name('body').send_keys('l')
browser.find_element(By.TAG_NAME, 'body').send_keys('l')
if enable_track_labels:
browser.find_element_by_tag_name('body').send_keys('k')
browser.find_element(By.TAG_NAME, 'body').send_keys('k')
from selenium.webdriver.support import expected_conditions as EC
time.sleep(15)
if 'reg' in overrides.keys():
element = browser.find_element_by_id("selected_registration")
element = browser.find_element(By.ID, "selected_registration")
browser.execute_script(f"arguments[0].innerText = '* {overrides['reg']}'", element)
reg = overrides['reg']
else:
try:
reg = browser.find_element_by_id("selected_registration").get_attribute("innerHTML")
try:
reg = browser.find_element(By.ID, "selected_registration").get_attribute("innerHTML")
print("Reg from tar1090 is", reg)
except Exception as e:
print("Couldn't find reg in tar1090", e)
reg = None
reg = None
if reg is not None:
try:
try:
photo_box = browser.find_element_by_id("silhouette")
photo_box = browser.find_element(By.ID, "silhouette")
except NoSuchElementException:
photo_box = browser.find_element_by_id("airplanePhoto")
photo_box = browser.find_element(By.ID, "airplanePhoto")
finally:
import requests, json
photo_list = json.loads(requests.get("https://raw.githubusercontent.com/Jxck-S/aircraft-photos/main/photo-list.json", timeout=20).text)
@ -87,7 +87,7 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
browser.execute_script("arguments[0].style.width = '200px';", photo_box)
browser.execute_script("arguments[0].style.float = 'left';", photo_box)
browser.execute_script(f"arguments[0].src = 'https://raw.githubusercontent.com/Jxck-S/aircraft-photos/main/images/{reg}.jpg';", photo_box)
image_copy_right = browser.find_element_by_id("copyrightInfo")
image_copy_right = browser.find_element(By.ID, "copyrightInfo")
browser.execute_cdp_cmd('Emulation.setScriptExecutionDisabled', {'value': True})
copy_right_children = image_copy_right.find_elements(By.XPATH, "*")
if len(copy_right_children) > 0:
@ -97,13 +97,13 @@ def get_adsbx_screenshot(file_path, url_params, enable_labels=False, enable_trac
except Exception as e:
print("Error on changing photo", e)
if 'type' in overrides.keys():
element = browser.find_element_by_id("selected_icaotype")
element = browser.find_element(By.ID, "selected_icaotype")
browser.execute_script(f"arguments[0].innerText = '* {overrides['type']}'", element)
if 'typelong' in overrides.keys():
element = browser.find_element_by_id("selected_typelong")
element = browser.find_element(By.ID, "selected_typelong")
browser.execute_script(f"arguments[0].innerText = '* {overrides['typelong']}'", element)
if 'ownop' in overrides.keys():
element = browser.find_element_by_id("selected_ownop")
element = browser.find_element(By.ID, "selected_ownop")
browser.execute_script(f"arguments[0].innerText = '* {overrides['ownop']}'", element)
time.sleep(5)
browser.save_screenshot(file_path)

10
planeClass.py

@ -437,7 +437,7 @@ class Plane:
getMap((municipality + ", " + state + ", " + country_code), self.map_file_name)
elif Plane.main_config.get('MAP', 'OPTION') == "ADSBX":
from defSS import get_adsbx_screenshot
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}"
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}&limitupdates=0"
get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
from modify_image import append_airport
text_credit = self.config.get('MAP', 'TEXT_CREDIT') if self.config.has_option('MAP', 'TEXT_CREDIT') else None
@ -559,7 +559,7 @@ class Plane:
getMap((municipality + ", " + state + ", " + country_code), self.map_file_name)
if Plane.main_config.get('MAP', 'OPTION') == "ADSBX":
from defSS import get_adsbx_screenshot
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}"
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}&limitupdates=0"
get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
if self.config.getboolean('DISCORD', 'ENABLE'):
dis_message = (self.dis_title + " " + squawk_message)
@ -582,7 +582,7 @@ class Plane:
dis_message = (self.dis_title + " " + mode + " mode enabled.")
if mode == "Approach":
from defSS import get_adsbx_screenshot
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}"
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}&limitupdates=0"
get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
sendDis(dis_message, self.config, None, self.map_file_name)
#elif mode in ["Althold", "VNAV", "LNAV"] and self.sel_nav_alt != None:
@ -765,7 +765,7 @@ class Plane:
return tfr_map_filename
from defSS import get_adsbx_screenshot
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}"
url_params = f"largeMode=2&hideButtons&hideSidebar&mapDim=0&zoom=10&icao={self.icao}&overlays={self.get_adsbx_map_overlays()}&limitupdates=0"
get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
if nearest_airport_dict['distance_mi'] < 3:
if "touchngo" in self.circle_history.keys():
@ -850,7 +850,7 @@ class Plane:
if bool(int(ra['acas_ra']['MTE'])):
ra_message += ", Multi threat"
from defSS import get_adsbx_screenshot, generate_adsbx_screenshot_time_params
url_params = f"&lat={ra['lat']}&lon={ra['lon']}&zoom=11&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays={self.get_adsbx_map_overlays()}"
url_params = f"&lat={ra['lat']}&lon={ra['lon']}&zoom=11&largeMode=2&hideButtons&hideSidebar&mapDim=0&overlays={self.get_adsbx_map_overlays()}&limitupdates=0"
if "threat_id_hex" in ra['acas_ra'].keys():
from mictronics_parse import get_aircraft_reg_by_icao
threat_reg = get_aircraft_reg_by_icao(ra['acas_ra']['threat_id_hex'])

Loading…
Cancel
Save