fix working direction not correct for windows. show upgrade chrome version message for diver-mode is uc.

master
CHUN YU YAO 2023-02-19 01:41:02 +08:00
parent 1703fc0b64
commit cc97bfe937
2 changed files with 18 additions and 6 deletions

View File

@ -279,7 +279,6 @@ def load_chromdriver_uc(webdriver_path, adblock_plus_enable):
print(CONST_CHROME_VERSION_NOT_MATCH_EN)
print(CONST_CHROME_VERSION_NOT_MATCH_TW)
is_local_chrome_browser_lower = True
#print(exc)
pass
if is_local_chrome_browser_lower:
@ -289,7 +288,20 @@ def load_chromdriver_uc(webdriver_path, adblock_plus_enable):
else:
print("Oops! web driver not on path:",chromedriver_path )
print('let uc automatically download chromedriver.')
driver = uc.Chrome(options=options, desired_capabilities=caps, suppress_welcome=False)
try:
driver = uc.Chrome(options=options, desired_capabilities=caps, suppress_welcome=False)
except Exception as exc:
error_message = str(exc)
left_part = None
if "Stacktrace:" in error_message:
left_part = error_message.split("Stacktrace:")[0]
print(left_part)
if "This version of ChromeDriver only supports Chrome version" in error_message:
print(CONST_CHROME_VERSION_NOT_MATCH_EN)
print(CONST_CHROME_VERSION_NOT_MATCH_TW)
is_local_chrome_browser_lower = True
pass
if driver is None:
print("create web drive object fail!")

View File

@ -688,19 +688,20 @@ def btn_run_clicked(language_code):
save_ret = btn_save_act(language_code, slience_mode=True)
print("save config result:", save_ret)
if save_ret:
working_dir = os.path.dirname(os.path.realpath(__file__))
if hasattr(sys, 'frozen'):
print("execute in frozen mode")
# check platform here.
if platform.system() == 'Darwin':
print("execute MacOS python script")
subprocess.Popen("./chrome_tixcraft", shell=True)
subprocess.Popen("./chrome_tixcraft", shell=True, cwd=working_dir)
if platform.system() == 'Linux':
print("execute linux binary")
subprocess.Popen("./chrome_tixcraft", shell=True)
subprocess.Popen("./chrome_tixcraft", shell=True, cwd=working_dir)
if platform.system() == 'Windows':
print("execute .exe binary.")
subprocess.Popen("chrome_tixcraft.exe", shell=True)
subprocess.Popen("chrome_tixcraft.exe", shell=True, cwd=working_dir)
else:
interpreter_binary = 'python'
interpreter_binary_alt = 'python3'
@ -709,7 +710,6 @@ def btn_run_clicked(language_code):
interpreter_binary = 'python3'
interpreter_binary_alt = 'python'
print("execute in shell mode.")
working_dir = os.path.dirname(os.path.realpath(__file__))
#print("script path:", working_dir)
#messagebox.showinfo(title="Debug0", message=working_dir)