From 89d1c2e1fc02459dd4a01ad4b30f90d19a2e9e73 Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Tue, 13 Sep 2022 21:29:18 +0800 Subject: [PATCH] ver 2022-09-13, due to python 2.x not work, change the execute script order --- README.md | 6 +++--- chrome_tixcraft.py | 3 +++ settings.py | 9 +++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 613defd..02c938a 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ the default path is the script path + "webdriver/chromedriver", My suggestion is PS: * this script only running in python3. (原始碼只可以在 python3 下執行。) -* 請先確定你的python 執行環境下已安裝 selenium 及 selenium-stealth 或相關的套件,請參考 pip-reg.txt 檔案內容。 -* 請到ChromeDriver網站 (https://chromedriver.chromium.org/) 下載與您目前相同版本的 ChromeDriver 的執行檔,放在搶票程式的webdriver目錄下(Mac電腦請放到 MaxBot.app 套件裡的 /Contents/Resources/webdriver/),在執行搶票程式前,第一次執行搶票主程式前,前請先手動點 ChromeDriver 的執行檔。 -* 最後透過 python3 執行 settings.py 就可以有 GUI 的設定界面。) +* 請先確定你的python 執行環境下已安裝 selenium 及相關的套件,請參考 pip-reg.txt 檔案內容。 +* 如果是 2022-09-13 之前的版本,請到ChromeDriver網站 (https://chromedriver.chromium.org/) 下載與您目前相同版本的 ChromeDriver 的執行檔,放在搶票程式的webdriver目錄下(Mac電腦請放到 MaxBot.app 套件裡的 /Contents/Resources/webdriver/),在執行搶票程式前,第一次執行搶票主程式前,前請先手動點 ChromeDriver 的執行檔。 +* 透過 python3 執行 settings.py 就可以有 GUI 的設定界面。 * 如果你是使用 macOS 並且執行環境沒有 python3,請 python 官方網站(https://www.python.org/downloads/)來安裝 python3, 如果在 macOS 裡會使用終端機(Terminal),建議使用 https://brew.sh/ 安裝 python3. * 如果你是使用 Firefox, ChromeDriver 的元件是叫 geckodriver,下載點在:https://github.com/mozilla/geckodriver/releases ,與 ChromeDriver 的處理方式是一樣,如果是 mac 電腦,要在元件按右鍵開啟,做一次授權的動作,mac 有2個版本,-macos.tar.gz 與 -macos-aarch64.tar.gz ,如果是 intel CPU 的版本,請服用前面沒有 aarch64 的版本。 diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index f861d1a..76e5f76 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -7,6 +7,9 @@ import json import random #print("python version", platform.python_version()) +# seleniumwire not support python 2.x. +# if you want running under python 2.x, you need to assign driver_type = 'stealth' +#driver_type = 'selenium' driver_type = 'stealth' driver_type = 'undetected_chromedriver' diff --git a/settings.py b/settings.py index f080187..2b1cb7d 100644 --- a/settings.py +++ b/settings.py @@ -153,15 +153,15 @@ def btn_save_act(slience_mode=False): return is_all_data_correct def btn_run_clicked(): + import subprocess + print('run button pressed.') Root_Dir = "" save_ret = btn_save_act(slience_mode=True) print("save config result:", save_ret) if save_ret: - import subprocess if hasattr(sys, 'frozen'): print("execute in frozen mode") - import platform # check platform here. if platform.system() == 'Darwin': @@ -176,6 +176,11 @@ def btn_run_clicked(): else: interpreter_binary = 'python' interpreter_binary_alt = 'python3' + + if platform.system() == 'Darwin': + # try python3 before python. + interpreter_binary = 'python3' + interpreter_binary_alt = 'python' print("execute in shell mode.") working_dir = os.path.dirname(os.path.realpath(__file__))