Args: executable_path: None = automatic a full file path to the chromedriver executable force: False terminate processes which are holding lock version_main: 0 = auto specify main chrome ver
(
self,
executable_path=None,
force=False,
version_main: int = 0,
user_multi_procs=False,
)
| 43 | data_path = os.path.abspath(os.path.expanduser(d)) |
| 44 | |
| 45 | def __init__( |
| 46 | self, |
| 47 | executable_path=None, |
| 48 | force=False, |
| 49 | version_main: int = 0, |
| 50 | user_multi_procs=False, |
| 51 | ): |
| 52 | """ |
| 53 | Args: |
| 54 | executable_path: None = automatic |
| 55 | a full file path to the chromedriver executable |
| 56 | force: False |
| 57 | terminate processes which are holding lock |
| 58 | version_main: 0 = auto |
| 59 | specify main chrome version (rounded, ex: 82) |
| 60 | """ |
| 61 | self.force = force |
| 62 | self._custom_exe_path = False |
| 63 | prefix = "undetected" |
| 64 | self.user_multi_procs = user_multi_procs |
| 65 | |
| 66 | try: |
| 67 | # Try to convert version_main into an integer |
| 68 | version_main_int = int(version_main) |
| 69 | # check if version_main_int is less than or equal to e.g 114 |
| 70 | self.is_old_chromedriver = version_main and version_main_int <= 114 |
| 71 | except (ValueError,TypeError): |
| 72 | # Check not running inside Docker |
| 73 | if not os.path.exists("/app/chromedriver"): |
| 74 | # If the conversion fails, log an error message |
| 75 | logging.info("version_main cannot be converted to an integer") |
| 76 | # Set self.is_old_chromedriver to False if the conversion fails |
| 77 | self.is_old_chromedriver = False |
| 78 | |
| 79 | # Needs to be called before self.exe_name is accessed |
| 80 | self._set_platform_name() |
| 81 | |
| 82 | if not os.path.exists(self.data_path): |
| 83 | os.makedirs(self.data_path, exist_ok=True) |
| 84 | |
| 85 | if not executable_path: |
| 86 | if sys.platform.startswith("freebsd"): |
| 87 | self.executable_path = os.path.join( |
| 88 | self.data_path, self.exe_name |
| 89 | ) |
| 90 | else: |
| 91 | self.executable_path = os.path.join( |
| 92 | self.data_path, "_".join([prefix, self.exe_name]) |
| 93 | ) |
| 94 | |
| 95 | if not IS_POSIX: |
| 96 | if executable_path: |
| 97 | if not executable_path[-4:] == ".exe": |
| 98 | executable_path += ".exe" |
| 99 | |
| 100 | self.zip_path = os.path.join(self.data_path, prefix) |
| 101 | |
| 102 | if not executable_path: |
nothing calls this directly
no test coverage detected