| 15 | |
| 16 | |
| 17 | class Patcher(object): |
| 18 | from seleniumbase.core import download_helper |
| 19 | |
| 20 | url_repo = "https://chromedriver.storage.googleapis.com" |
| 21 | zip_name = "chromedriver_%s.zip" |
| 22 | exe_name = "chromedriver%s" |
| 23 | sys_plat = sys.platform |
| 24 | # downloads_folder = "~/.undetected_drivers" |
| 25 | if sys_plat.endswith("win32"): |
| 26 | zip_name %= "win32" |
| 27 | exe_name %= ".exe" |
| 28 | # downloads_folder = "~/appdata/roaming/undetected_drivers" |
| 29 | if sys_plat.endswith("linux"): |
| 30 | zip_name %= "linux64" |
| 31 | exe_name %= "" |
| 32 | # downloads_folder = "~/.local/share/undetected_drivers" |
| 33 | if sys_plat.endswith("darwin"): |
| 34 | zip_name %= "mac64" |
| 35 | exe_name %= "" |
| 36 | # downloads_folder = "~/Library/Application Support/undetected_drivers" |
| 37 | downloads_folder = download_helper.get_downloads_folder() |
| 38 | if not os.path.exists(downloads_folder): |
| 39 | try: |
| 40 | os.makedirs(downloads_folder, exist_ok=True) |
| 41 | except Exception: |
| 42 | pass # Only possible during multithreaded tests |
| 43 | data_path = os.path.abspath(os.path.expanduser(downloads_folder)) |
| 44 | |
| 45 | def __init__(self, executable_path=None, force=False, version_main=0): |
| 46 | """Args: |
| 47 | executable_path: None = automatic |
| 48 | A full file path to the chromedriver executable |
| 49 | force: False |
| 50 | Terminate processes which are holding lock |
| 51 | version_main: 0 = auto |
| 52 | Specify main chrome version (rounded, ex: 82) """ |
| 53 | self.force = force |
| 54 | self.executable_path = None |
| 55 | prefix = "undetected" |
| 56 | if not os.path.exists(self.data_path): |
| 57 | with suppress(Exception): |
| 58 | os.makedirs(self.data_path, exist_ok=True) |
| 59 | if not executable_path: |
| 60 | self.executable_path = os.path.join( |
| 61 | self.data_path, "_".join([prefix, self.exe_name]) |
| 62 | ) |
| 63 | if not IS_POSIX: |
| 64 | if executable_path: |
| 65 | if not executable_path[-4:] == ".exe": |
| 66 | executable_path += ".exe" |
| 67 | self.zip_path = os.path.join(self.data_path, prefix) |
| 68 | if not executable_path: |
| 69 | self.executable_path = os.path.abspath( |
| 70 | os.path.join(".", self.executable_path) |
| 71 | ) |
| 72 | self._custom_exe_path = False |
| 73 | if executable_path: |
| 74 | self._custom_exe_path = True |
no test coverage detected
searching dependent graphs…