2023-03-07 add verbose mode to display debug message on your environment.

master
CHUN YU YAO 2023-03-07 22:30:30 +08:00
parent 163036521b
commit 7abe47b0c4
4 changed files with 53 additions and 15 deletions

View File

@ -53,7 +53,7 @@ import argparse
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = u"MaxBot (2023.03.06)"
CONST_APP_VERSION = u"MaxBot (2023.03.07)"
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
URL_GOOGLE_OAUTH = 'https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow'
@ -1299,6 +1299,9 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
show_debug_message = True # debug.
show_debug_message = False # online
if config_dict["advanced"]["verbose"]:
show_debug_message = True
# read config.
auto_select_mode = config_dict["tixcraft"]["date_auto_select"]["mode"]
date_keyword = config_dict["tixcraft"]["date_auto_select"]["date_keyword"].strip()
@ -1394,6 +1397,8 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
is_match_all_coming_soon_condiction = False
break
if is_match_all_coming_soon_condiction:
if show_debug_message:
print("match coming soon condiction at row:", row_text)
is_coming_soon = True
break
@ -1486,23 +1491,26 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
target_area = matched_blocks[target_row_index]
is_date_selected = False
is_date_clicked = False
if target_area is not None:
target_button = None
try:
target_button = target_area.find_element(By.CSS_SELECTOR, 'button')
if target_button.is_enabled():
if not target_button is None:
if target_button.is_enabled():
if show_debug_message:
print("start to press button...")
target_button.click()
is_date_clicked = True
else:
if show_debug_message:
print("pressing button...")
target_button.click()
is_date_selected = True
print("target_button in target row is None.")
except Exception as exc:
if show_debug_message:
print("find or press button fail")
print("find or press button fail:", exc)
if not target_button is None:
print("try to click button fail, force click by js.")
#print(exc)
try:
driver.execute_script("arguments[0].click();", target_button)
except Exception as exc:
@ -1520,7 +1528,7 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
except Exception as exc:
pass
else:
if not is_date_selected:
if not is_date_clicked:
if not formated_area_list is None:
if len(formated_area_list) == 0:
try:
@ -1529,7 +1537,7 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
except Exception as exc:
pass
return is_date_selected
return is_date_clicked
# PURPOSE: get target area list.
# RETURN:
@ -1655,6 +1663,9 @@ def tixcraft_area_auto_select(driver, url, config_dict):
show_debug_message = True # debug.
show_debug_message = False # online
if config_dict["advanced"]["verbose"]:
show_debug_message = True
# read config.
area_keyword_1 = config_dict["tixcraft"]["area_auto_select"]["area_keyword_1"].strip()
area_keyword_2 = config_dict["tixcraft"]["area_auto_select"]["area_keyword_2"].strip()
@ -3303,6 +3314,9 @@ def kktix_reg_new_main(driver, answer_index, is_finish_checkbox_click, config_di
show_debug_message = True # debug.
show_debug_message = False # online
if config_dict["advanced"]["verbose"]:
show_debug_message = True
# part 1: check div.
registrationsNewApp_div = None
try:

View File

@ -20,7 +20,7 @@ import json
import webbrowser
import base64
CONST_APP_VERSION = u"MaxBot (2023.03.06)"
CONST_APP_VERSION = u"MaxBot (2023.03.07)"
CONST_LAUNCHER_CONFIG_FILENAME = "config_launcher.json"

View File

@ -1 +1 @@
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": "", "presale_code_delimiter": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false, "headless": false}, "debug": false}
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": "", "presale_code_delimiter": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false, "headless": false, "verbose": false}}

View File

@ -21,7 +21,7 @@ import webbrowser
import pyperclip
import base64
CONST_APP_VERSION = u"MaxBot (2023.03.06)"
CONST_APP_VERSION = u"MaxBot (2023.03.07)"
CONST_SETTINGS_CONFIG_FILENAME = "settings.json"
@ -96,6 +96,8 @@ def load_translate():
en_us["ocr_captcha_image_source"] = 'OCR image source'
en_us["webdriver_type"] = 'WebDriver type'
en_us["headless"] = 'Headless mode'
# Make the operation more talkative
en_us["verbose"] = 'Verbose mode'
en_us["preference"] = 'Preference'
en_us["advanced"] = 'Advanced'
@ -175,6 +177,7 @@ def load_translate():
zh_tw["ocr_captcha_image_source"] = 'OCR圖片取得方式'
zh_tw["webdriver_type"] = 'WebDriver類別'
zh_tw["headless"] = '無圖形界面模式'
zh_tw["verbose"] = '輸出詳細除錯訊息'
zh_tw["preference"] = '偏好設定'
zh_tw["advanced"] = '進階設定'
@ -254,6 +257,7 @@ def load_translate():
zh_cn["ocr_captcha_image_source"] = 'OCR图像源'
zh_cn["webdriver_type"] = 'WebDriver类别'
zh_cn["headless"] = '无图形界面模式'
zh_cn["verbose"] = '输出详细除错讯息'
zh_cn["preference"] = '偏好设定'
zh_cn["advanced"] = '進階設定'
@ -334,6 +338,7 @@ def load_translate():
ja_jp["ocr_captcha_image_source"] = 'OCR 画像ソース'
ja_jp["webdriver_type"] = 'WebDriverタイプ'
ja_jp["headless"] = 'ヘッドレスモード'
ja_jp["verbose"] = '詳細モード'
ja_jp["preference"] = '設定'
ja_jp["advanced"] = '高度な設定'
@ -484,8 +489,7 @@ def get_default_config():
config_dict["advanced"]["adblock_plus_enable"] = False
config_dict["advanced"]["open_google_oauth_url"] = False
config_dict["advanced"]["headless"] = False
config_dict['debug']=False
config_dict["advanced"]["verbose"] = False
return config_dict
@ -633,6 +637,7 @@ def btn_save_act(language_code, slience_mode=False):
global chk_state_ocr_captcha_force_submit
global chk_state_google_oauth
global chk_state_headless
global chk_state_verbose
global combo_ocr_captcha_image_source
global combo_webdriver_type
@ -746,6 +751,7 @@ def btn_save_act(language_code, slience_mode=False):
config_dict["ocr_captcha"]["image_source"] = combo_ocr_captcha_image_source.get().strip()
config_dict["webdriver_type"] = combo_webdriver_type.get().strip()
config_dict["advanced"]["headless"] = bool(chk_state_headless.get())
config_dict["advanced"]["verbose"] = bool(chk_state_verbose.get())
# save config.
if is_all_data_correct:
@ -921,6 +927,7 @@ def applyNewLanguage():
global lbl_ocr_captcha_image_source
global lbl_webdriver_type
global lbl_headless
global lbl_verbose
# for checkbox
global chk_pass_1_seat_remaining
@ -939,6 +946,7 @@ def applyNewLanguage():
global chk_ocr_captcha_force_submit
global chk_google_oauth
global chk_headless
global chk_verbose
global chk_kktix_area_keyword_2_enable
global chk_area_keyword_2_enable
@ -993,6 +1001,7 @@ def applyNewLanguage():
lbl_webdriver_type.config(text=translate[language_code]["webdriver_type"])
lbl_google_oauth.config(text=translate[language_code]["open_google_oauth_url"])
lbl_headless.config(text=translate[language_code]["headless"])
lbl_verbose.config(text=translate[language_code]["verbose"])
chk_pass_1_seat_remaining.config(text=translate[language_code]["enable"])
chk_auto_check_agree.config(text=translate[language_code]["enable"])
@ -1009,6 +1018,7 @@ def applyNewLanguage():
chk_ocr_captcha_force_submit.config(text=translate[language_code]["enable"])
chk_google_oauth.config(text=translate[language_code]["enable"])
chk_headless.config(text=translate[language_code]["enable"])
chk_verbose.config(text=translate[language_code]["enable"])
chk_kktix_area_keyword_2_enable.config(text=translate[language_code]["enable"])
chk_area_keyword_2_enable.config(text=translate[language_code]["enable"])
@ -2029,6 +2039,20 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X):
chk_headless = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_headless)
chk_headless.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
global lbl_verbose
lbl_verbose = Label(frame_group_header, text=translate[language_code]['verbose'])
lbl_verbose.grid(column=0, row=group_row_count, sticky = E)
global chk_state_verbose
chk_state_verbose = BooleanVar()
chk_state_verbose.set(config_dict['advanced']["verbose"])
global chk_verbose
chk_verbose = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_verbose)
chk_verbose.grid(column=1, row=group_row_count, sticky = W)
frame_group_header.grid(column=0, row=row_count, padx=UI_PADDING_X)
def AutofillTab(root, config_dict, language_code, UI_PADDING_X):