added v2 as namespace in __init__, and for v1 added ChromeoptionsV2, which is just v2.ChromeOptions

This commit is contained in:
UltrafunkAmsterdam 2021-06-27 13:59:20 +02:00
parent fd9b6d5fd7
commit 7ddbfd00d0
2 changed files with 13 additions and 3 deletions

View File

@ -29,7 +29,10 @@ from urllib.request import urlopen, urlretrieve
from selenium.webdriver import Chrome as _Chrome, ChromeOptions as _ChromeOptions
from . import v2
from . import cdp
from . import options
ChromeOptionsV2 = v2.ChromeOptions
logger = logging.getLogger(__name__)
__version__ = "3.0.2"

View File

@ -21,8 +21,9 @@ import selenium.webdriver.remote.webdriver
from .options import ChromeOptions
from .patcher import IS_POSIX, Patcher
from .reactor import Reactor
from .cdp import CDP
__all__ = ("Chrome", "ChromeOptions", "Patcher", "Reactor", "find_chrome_executable")
__all__ = ("Chrome", "ChromeOptions", "Patcher", "Reactor", "CDP", "find_chrome_executable")
logger = logging.getLogger("uc")
logger.setLevel(logging.getLogger().getEffectiveLevel())
@ -570,7 +571,9 @@ class Chrome(selenium.webdriver.Chrome):
except Exception: # noqa
pass
if not self.keep_user_data_dir or self.keep_user_data_dir is False:
if hasattr(self, 'keep_user_data_dir') \
and not self.keep_user_data_dir \
or self.keep_user_data_dir is False:
for _ in range(3):
try:
logger.debug("removing profile : %s" % self.user_data_dir)
@ -581,9 +584,13 @@ class Chrome(selenium.webdriver.Chrome):
logger.debug(
"permission error. files are still in use/locked. retying..."
)
except (RuntimeError, OSError) as e:
logger.debug(
"%s retying..." % e
)
else:
break
time.sleep(1)
time.sleep(.25)
def __del__(self):
logger.debug("Chrome.__del__")