From 8787db385eec227f2c101544363d02d2d285cc24 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Sat, 20 Jan 2024 18:36:04 +0100 Subject: Check access from chromedriver --- etc/tool/copilot.py | 2 +- g4f/webdriver.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/etc/tool/copilot.py b/etc/tool/copilot.py index 62698c70..4de53ffc 100644 --- a/etc/tool/copilot.py +++ b/etc/tool/copilot.py @@ -16,7 +16,7 @@ g4f.debug.logging = True g4f.debug.version_check = False GITHUB_TOKEN = os.getenv('GITHUB_TOKEN') -G4F_PROVIDER = os.getenv('G4F_PROVIDER') or g4f.Provider.OpenaiChat +G4F_PROVIDER = os.getenv('G4F_PROVIDER') G4F_MODEL = os.getenv('G4F_MODEL') or g4f.models.gpt_4 def get_pr_details(github: Github) -> PullRequest: diff --git a/g4f/webdriver.py b/g4f/webdriver.py index 9a83215f..85d6d695 100644 --- a/g4f/webdriver.py +++ b/g4f/webdriver.py @@ -6,6 +6,7 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from os import path +from os import access, R_OK from . import debug try: @@ -40,8 +41,9 @@ def get_browser( options = ChromeOptions() if proxy: options.add_argument(f'--proxy-server={proxy}') + # Check for system driver in docker driver = '/usr/bin/chromedriver' - if not path.isfile(driver): + if not path.isfile(driver) or not access(driver, R_OK): driver = None return Chrome( options=options, -- cgit v1.2.3