add debug messages for launch chrome fail...

master
Max 2023-08-07 11:20:50 +08:00 committed by GitHub
parent d1d69d10ac
commit 01e04f841b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 14 deletions

View File

@ -54,7 +54,7 @@ import webbrowser
import argparse import argparse
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.08.02)" CONST_APP_VERSION = "MaxBot (2023.08.03)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -416,8 +416,8 @@ def load_chromdriver_normal(config_dict, driver_type):
os.mkdir(webdriver_path) os.mkdir(webdriver_path)
if not os.path.exists(chromedriver_path): if not os.path.exists(chromedriver_path):
print("WebDriver not exist, try to download...") print("WebDriver not exist, try to download to:", webdriver_path)
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False) chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
if not os.path.exists(chromedriver_path): if not os.path.exists(chromedriver_path):
print("Please download chromedriver and extract zip to webdriver folder from this url:") print("Please download chromedriver and extract zip to webdriver folder from this url:")
@ -472,7 +472,6 @@ def load_chromdriver_normal(config_dict, driver_type):
return driver return driver
def clean_uc_exe_cache(): def clean_uc_exe_cache():
is_cache_exist = False
exe_name = "chromedriver%s" exe_name = "chromedriver%s"
platform = sys.platform platform = sys.platform
@ -496,16 +495,16 @@ def clean_uc_exe_cache():
d = "~/.undetected_chromedriver" d = "~/.undetected_chromedriver"
data_path = os.path.abspath(os.path.expanduser(d)) data_path = os.path.abspath(os.path.expanduser(d))
is_cache_exist = False
p = pathlib.Path(data_path) p = pathlib.Path(data_path)
files = list(p.rglob("*chromedriver*?")) files = list(p.rglob("*chromedriver*?"))
for file in files: for file in files:
is_cache_exist = True
if os.path.exists(str(file)): if os.path.exists(str(file)):
is_cache_exist = True
try: try:
os.unlink(str(file)) os.unlink(str(file))
except PermissionError: except Exception as exc2:
pass print(exc2)
except FileNotFoundError:
pass pass
return is_cache_exist return is_cache_exist
@ -527,8 +526,10 @@ def load_chromdriver_uc(config_dict):
os.mkdir(webdriver_path) os.mkdir(webdriver_path)
if not os.path.exists(chromedriver_path): if not os.path.exists(chromedriver_path):
print("WebDriver not exist, try to download...") print("ChromeDriver not exist, try to download to:", webdriver_path)
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False) chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
else:
print("ChromeDriver exist:", chromedriver_path)
options = uc.ChromeOptions() options = uc.ChromeOptions()
options.page_load_strategy = 'eager' options.page_load_strategy = 'eager'
@ -586,13 +587,13 @@ def load_chromdriver_uc(config_dict):
# remove exist chromedriver, download again. # remove exist chromedriver, download again.
try: try:
print("Deleting exist and download ChromeDriver again.")
os.unlink(chromedriver_path) os.unlink(chromedriver_path)
except PermissionError: except Exception as exc2:
pass print(exc2)
except FileNotFoundError:
pass pass
chromedriver_autoinstaller.install(path="webdriver", make_version_dir=False) chromedriver_autoinstaller.install(path=webdriver_path, make_version_dir=False)
try: try:
driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options, headless=config_dict["advanced"]["headless"]) driver = uc.Chrome(driver_executable_path=chromedriver_path, options=options, headless=config_dict["advanced"]["headless"])
except Exception as exc2: except Exception as exc2: