Jxck-S / plane-notify

Notify if a selected plane has taken off or landed using ADS-B data. Compares older data to newer data to determine if a landing or takeoff has occurred. As well as nav modes, emergency squawk and resolution advisory notifications. Can output to Twitter, Discord, Mastodon, and Telegram
GNU General Public License v3.0
2.5k stars 437 forks source link

Chromium failing to screenshot #51

Closed RigaOnTheRocks closed 2 years ago

RigaOnTheRocks commented 2 years ago

Device

Tested on Raspberrypi 3B+ and Ubuntu 20.04.4 (both with the correct arch for Chromium)

Bug description

When a landing event occurs, the screenshot function fails as Chromium (browser/driver) isn't correctly recognized, and so crash without taking the screenshot to send it over Twitter, also quitting the program.

Output for Raspberrypi

====== WebDriver manager ======
Could not get version for google-chrome.Is google-chrome installed?
Get LATEST chromedriver version for None google-chrome
There is no [linux32] chromedriver for browser None in cache
Trying to download new driver from https://chromedriver.storage.googleapis.com/102.0.5005.61/chromedriver_linux32.zip
Traceback (most recent call last):
  File "/home/pi/plane-notify/__main__.py", line 217, in <module>
    raise e
  File "/home/pi/plane-notify/__main__.py", line 165, in <module>
    obj.run_opens(dataState)
  File "/home/pi/plane-notify/planeClass.py", line 98, in run_opens
    self.run_check()
  File "/home/pi/plane-notify/planeClass.py", line 440, in run_check
    get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
  File "/home/pi/plane-notify/defSS.py", line 21, in get_adsbx_screenshot
    browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
  File "/home/pi/.local/share/virtualenvs/plane-notify-lBc-1MAR/lib/python3.9/site-packages/webdriver_manager/chrome.py", line 32, in install
    driver_path = self._get_driver_path(self.driver)
  File "/home/pi/.local/share/virtualenvs/plane-notify-lBc-1MAR/lib/python3.9/site-packages/webdriver_manager/manager.py", line 23, in _get_driver_path
    file = download_file(driver.get_url(), driver.ssl_verify)
  File "/home/pi/.local/share/virtualenvs/plane-notify-lBc-1MAR/lib/python3.9/site-packages/webdriver_manager/utils.py", line 102, in download_file
    validate_response(response)
  File "/home/pi/.local/share/virtualenvs/plane-notify-lBc-1MAR/lib/python3.9/site-packages/webdriver_manager/utils.py", line 90, in validate_response
    raise ValueError("There is no such driver by url {}".format(resp.url))
ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/102.0.5005.61/chromedriver_linux32.zip

Output for Ubuntu 20.04.4

====== WebDriver manager ======
Could not get version for google-chrome.Is google-chrome installed?
Get LATEST chromedriver version for None google-chrome
Driver [/home/user/.wdm/drivers/chromedriver/linux64/102.0.5005.61/chromedriver] found in cache
Traceback (most recent call last):
  File "/home/user/Documents/plane-notify/__main__.py", line 217, in <module>
    raise e
  File "/home/user/Documents/plane-notify/__main__.py", line 172, in <module>
    obj.run_empty()
  File "/home/user/Documents/plane-notify/planeClass.py", line 276, in run_empty
    self.run_check()
  File "/home/user/Documents/plane-notify/planeClass.py", line 440, in run_check
    get_adsbx_screenshot(self.map_file_name, url_params, overrides=self.overrides)
  File "/home/user/Documents/plane-notify/defSS.py", line 21, in get_adsbx_screenshot
    browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 93, in __init__
    RemoteWebDriver.__init__(
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
    self.error_handler.check_response(response)
  File "/home/user/.local/share/virtualenvs/plane-notify-IzQ_oObS/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/local/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
#0 0x55a23b5dbf33 <unknown>
#1 0x55a23b326118 <unknown>
#2 0x55a23b349678 <unknown>
#3 0x55a23b344d5a <unknown>
#4 0x55a23b37fd3a <unknown>
#5 0x55a23b379e63 <unknown>
#6 0x55a23b34f82a <unknown>
#7 0x55a23b350985 <unknown>
#8 0x55a23b6204cd <unknown>
#9 0x55a23b6245ec <unknown>
#10 0x55a23b60a71e <unknown>
#11 0x55a23b625238 <unknown>
#12 0x55a23b5ff870 <unknown>
#13 0x55a23b641608 <unknown>
#14 0x55a23b641788 <unknown>
#15 0x55a23b65bf1d <unknown>
#16 0x7f7c5ac7d609 <unknown>

Observations

Chromedriver works fine (and is the same version as browser in case of).

/usr/lib/chromium-browser/chromedriver
Starting ChromeDriver 102.0.5005.63 (898ca5734597d1583932dfeaec82dd24db2e5d62-refs/heads/main@{#999047}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

As there's no GUI on the raspberrypi, Chromium browser can't run by himself (shouldn't be a problem considering defSS.py).

chromium-browser
/etc/chromium.d/README: line 1: Any: command not found
[27639:27639:0608/175454.647174:ERROR:ozone_platform_x11.cc(247)] Missing X server or $DISPLAY
[27639:27639:0608/175454.657399:ERROR:env.cc(225)] The platform failed to initialize.  Exiting.

Any idea about this issue ? Thanks.

hDmtP commented 2 years ago

This may sound vague but have you tried restarting your system and then trying it again?

RigaOnTheRocks commented 2 years ago

This may sound vague but have you tried restarting your system and then trying it again?

Hey, yes I tried and it didn't change anything. I switched to Debian as Chromium and ARM aren't compatible enough, so now things are running smoothly.