From cc97bfe937d953e7c9e951864f913e20998784ad Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Sun, 19 Feb 2023 01:41:02 +0800 Subject: [PATCH] fix working direction not correct for windows. show upgrade chrome version message for diver-mode is uc. --- chrome_tixcraft.py | 16 ++++++++++++++-- settings.py | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 61fe0d1..77ad6ca 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -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!") diff --git a/settings.py b/settings.py index 66abad5..3fc4a10 100644 --- a/settings.py +++ b/settings.py @@ -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)