From 03acb962ac5c28d3b17758c803ef28fa1c1157ef Mon Sep 17 00:00:00 2001 From: Scott Ladewig Date: Sat, 30 Jul 2022 21:31:41 -0500 Subject: [PATCH 1/4] Update config (#1) * Update config Added map_parameters to config and set to null to avoid error when being parsed. Updated FlightAware AeroAPI info to reflect current information. * Corrected typo Corrected typo caused by accidental deletion of characters in a comment. * Edited FlightAware API comment Corrected grammar of the FlightAware API comment. --- config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config b/config index 7553181..b0a2d85 100644 --- a/config +++ b/config @@ -2,6 +2,7 @@ driver = dump1090 data_url = http://localhost/tar1090/data/aircraft.json map_url = http://localhost/tar1090/ +map_parameters = None request_timeout = 60 ; An airplane is only tracked and tweeted when it enters the "alarm area" the alarm area @@ -76,9 +77,9 @@ access_token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX access_token_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [flightaware] -; FlightAware API allows to get more information on the flights. Basic API access is now free -; and if you are FA feeder, your request limit is doubled. For more details check: -; https://flightaware.com/commercial/flightxml/pricing_class.rvt +; FlightAware API provides additional information about flights. The personal tier is free, and +; if you are a FlightAware feeder, you receive $10 of Per-Query fees free each month. For more +; details: https://flightaware.com/commercial/aeroapi/#compare-plans-section fa_enable = False fa_username = XXXXXXXX fa_api_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX From de7fece182b197edfd31e4c23db5b45b8f9a194a Mon Sep 17 00:00:00 2001 From: Scott Ladewig Date: Sat, 30 Jul 2022 22:33:41 -0500 Subject: [PATCH 2/4] Add logic for nohup.out deletion to runbot.sh The runbot.sh script attempts to remove nohup.out without checking whether it exists first which can cause a warning/error. THis change adds logic to only attempt to delete the file if it exists. Also adds a variable that can be used to indicate if nohup.out is desired without having to comment/uncomment lines. --- runbot.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/runbot.sh b/runbot.sh index c25a7b7..efc059c 100755 --- a/runbot.sh +++ b/runbot.sh @@ -1,3 +1,14 @@ -rm nohup.out -#nohup ./run_tracker.sh & -nohup ./run_tracker.sh /dev/null 2>&1 & +# Set nohup to 1 to write to nohup +nohup=0 + +if [[ -f nohup.out ]] +then + rm nohup.out +fi + +if [ $nohup == 1 ] +then + nohup ./run_tracker.sh & +else + nohup ./run_tracker.sh /dev/null 2>&1 & +fi \ No newline at end of file From 0d1e1a3e55a65e2018b174294bc0a1659c5d7bdd Mon Sep 17 00:00:00 2001 From: Scott Ladewig Date: Sun, 31 Jul 2022 20:08:53 -0500 Subject: [PATCH 3/4] Add support for Selenium 4.3.0, Correct ClickOnAirplane issue - Selenium 4.3.0 deprecated the find_element(s)_xxx commands causing exceptions for installs with the new version. This change adds support for the 4.3.0 commands while retaining support for older installs of Selenium. It does not add any new functionality from 4.3.0. - In ClickOnAirplane, aircraft rows were found by looking for the hex value in \. The hex column isn't displayed by default in tar1090, however, which causes an error when trying to find the aircraft. Changed it to look at the id in \ which is always available. --- screenshot.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/screenshot.py b/screenshot.py index 4d71a16..8388163 100755 --- a/screenshot.py +++ b/screenshot.py @@ -4,6 +4,7 @@ # kevinabrandon@gmail.com # # edit by simon@sandm.co.uk to use Chromedriver +# edit by scott@ladewig.com to work for either Selenium 4.3.0+ or older version originally used import sys import time @@ -37,6 +38,17 @@ # options = webdriver.FirefoxOptions() # options.add_argument("--headless") +# Checking to see if we need to use Selenium 4.3.0+ commands or pre4.3.0. +webdriverversion = (webdriver.__version__).split(".") +webdriverversionmajor = int(webdriverversion[0]) +webdriverversionminor = int(webdriverversion[1]) + +if (webdriverversionmajor == 4 and webdriverversionminor >= 3) or webdriverversionmajor > 4: + usedeprecated = False +else: + usedeprecated = True + + # Check for Crop settings if parser.has_section('crop'): do_crop = parser.getboolean('crop', 'do_crop') @@ -130,18 +142,27 @@ def loadmap(self): raise print("reset map:") - resetbutton = browser.find_elements_by_xpath('//*[contains(@title,"Reset Map")]') + if usedeprecated: + resetbutton = browser.find_elements_by_xpath('//*[contains(@title,"Reset Map")]') + else: + resetbutton = browser.find_elements(By.XPATH, '//*[contains(@title,"Reset Map")]') resetbutton[0].click() print("zoom in 3 times:") try: # First look for the Open Layers map zoom button. - zoomin = browser.find_element_by_class_name('ol-zoom-in') + if usedeprecated: + zoomin = browser.find_element_by_class_name('ol-zoom-in') + else: + zoomin = browser.find_element(By.CLASS_NAME, 'ol-zoom-in') print("Zoom: ",zoomin) except seleniumexceptions.NoSuchElementException as e: # Doesn't seem to be Open Layers, so look for the Google # maps zoom button. - zoomin = browser.find_elements_by_xpath('//*[@title="Zoom in"]') + if usedeprecated: + zoomin = browser.find_elements_by_xpath('//*[@title="Zoom in"]') + else: + zoomin = browser.find_elements(By.XPATH, '//*[@title="Zoom in"]') if zoomin: zoomin = zoomin[0] zoomin.click() @@ -156,7 +177,10 @@ def clickOnAirplane(self, text): ''' print(text) try: - element = self.browser.find_elements_by_xpath("//td[text()='%s']" % text.lower()) + if usedeprecated: + element = self.browser.find_elements_by_xpath("//tr[@id='%s']" % text.lower()) + else: + element = self.browser.find_elements(By.XPATH, "//tr[@id='%s']" % text.lower()) print("number of elements found: %i" % len(element)) if len(element) > 0: print("clicking on {}!".format(text)) @@ -199,7 +223,10 @@ def clickOnAirplane(self, text): Clicks on the airplane with the name text, and then takes a screenshot ''' try: - aircraft = self.browser.find_element_by_xpath("//td[text()='%s']" % text) + if usedeprecated: + aircraft = self.browser.find_element_by_xpath("//tr[@id=='%s']" % text) + else: + aircraft = self.browser.find_element(By.XPATH, "//tr[@id='%s']" % text) aircraft.click() time.sleep(0.5) # if we don't wait a little bit the airplane icon isn't drawn. show_on_map = self.browser.find_element_by_link_text('Show on map') From 3e8fd53726e9464ea5c34a8744e98a4e5df3ad17 Mon Sep 17 00:00:00 2001 From: Scott Ladewig Date: Sun, 7 Aug 2022 14:40:42 -0500 Subject: [PATCH 4/4] Update flightdata.py The original code is looking for "speed" in the aircraft.json file, but dump1090-fa uses "gs" (ground speed) instead. Added check for "gs" to allow speed to be reported for dump1090-fa users. This same fix was submitted to OverPutney by derektgardner (Update flightdata.py #9) --- flightdata.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flightdata.py b/flightdata.py index e2945ae..e00b19a 100755 --- a/flightdata.py +++ b/flightdata.py @@ -201,6 +201,8 @@ def aircraft_data(self, json_data, time): speed = 0 if "speed" in a: speed = geomath.knot2mph(a["speed"]) + if "gs" in a: + speed = geomath.knot2mph(a["gs"]) if "mach" in a: speed = geomath.mach2mph(a["mach"])