Skip to content

Commit

Permalink
2024-03-05, bugs fixed for kktix_status.
Browse files Browse the repository at this point in the history
  • Loading branch information
hahamic committed Mar 17, 2024
1 parent b12494d commit 053d7f1
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 85 deletions.
2 changes: 1 addition & 1 deletion chrome_tixcraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
except Exception as exc:
pass

CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"

CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
Expand Down
6 changes: 2 additions & 4 deletions config_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
# for Python3
try:
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
from tkinter import filedialog, messagebox, ttk
except Exception as e:
pass

Expand All @@ -25,7 +23,7 @@
import threading
import webbrowser

CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"

CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
Expand Down
49 changes: 24 additions & 25 deletions kktix_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
# for Python3
try:
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
from tkinter import filedialog, messagebox, ttk
except Exception as e:
pass

Expand All @@ -25,12 +23,13 @@
import subprocess
import sys
import threading
import webbrowser
import requests
import time
import webbrowser
from datetime import datetime

CONST_APP_VERSION = "MaxBot (2024.03.04)"
import requests

CONST_APP_VERSION = "MaxBot (2024.03.05)"

CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json"
Expand Down Expand Up @@ -845,7 +844,7 @@ def kktix_get_registerStatus(event_code):
print("send reg_info request fail:")
print(exc)

registerStatus = None
registerStatus = ""
if not html_result is None:
status_code = html_result.status_code
#print("status_code:",status_code)
Expand Down Expand Up @@ -881,12 +880,12 @@ def kktix_get_event_code(url):

def kktix_in_stock_play_sound():
global chk_state_play_ticket_sound
try:
if 'chk_state_play_ticket_sound' in globals():
if 'chk_state_play_ticket_sound' in globals():
try:
if bool(chk_state_play_ticket_sound.get()):
btn_preview_sound_clicked()
except Exception as e:
pass
except Exception as e:
pass

def get_kktix_status_by_url(url):
registerStatus = ""
Expand All @@ -900,19 +899,19 @@ def get_kktix_status_by_url(url):

def update_kktix_status(registerStatus):
global status_variable
try:
if 'status_variable' in globals():
if 'status_variable' in globals():
try:
status_variable.set(registerStatus)
except Exception as e:
pass
except Exception as e:
pass

def append_kktix_status_log(output_log):
global txt_status_log
try:
if 'txt_status_log' in globals():
if 'txt_status_log' in globals():
try:
txt_status_log.insert("1.0", output_log + "\n")
except Exception as e:
pass
except Exception as e:
pass

def append_kktix_status_log_file(output_log):
app_root = get_app_root()
Expand Down Expand Up @@ -972,14 +971,14 @@ def collect_ui_config():
check_interval = 3
config_filepath, config_dict = load_json()

try:
if 'combo_check_interval' in globals():
if 'combo_check_interval' in globals():
try:
check_interval = int(combo_check_interval.get().strip())
config_dict["check_interval"] = check_interval
else:
is_ui_ready = False
except Exception as e:
pass
except Exception as e:
pass
else:
is_ui_ready = False

url = ""
filename = ""
Expand Down
133 changes: 78 additions & 55 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
except ImportError:
# for Python3
try:
from tkinter import *
from tkinter import ttk
import tkinter.font as tkfont
from tkinter import messagebox
from tkinter import *
from tkinter import messagebox, ttk
from tkinter.filedialog import asksaveasfilename
except Exception as e:
pass
Expand Down Expand Up @@ -51,7 +50,7 @@
except Exception as exc:
pass

CONST_APP_VERSION = "MaxBot (2024.03.04)"
CONST_APP_VERSION = "MaxBot (2024.03.05)"

CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
Expand Down Expand Up @@ -1198,10 +1197,11 @@ def show_preview_text():
date_array = []

global lbl_online_dictionary_preview_data
try:
lbl_online_dictionary_preview_data.config(text=','.join(date_array))
except Exception as exc:
pass
if 'lbl_online_dictionary_preview_data' in globals():
try:
lbl_online_dictionary_preview_data.config(text=','.join(date_array))
except Exception as exc:
pass

def write_string_to_file(filename, data):
outfile = None
Expand Down Expand Up @@ -1245,11 +1245,13 @@ def save_url_to_file(new_remote_url, force_write = False):
def btn_preview_text_clicked():
global txt_remote_url
remote_url = ""
try:
remote_url = txt_remote_url.get("1.0",END).strip()
except Exception as exc:
pass
if 'txt_remote_url' in globals():
try:
remote_url = txt_remote_url.get("1.0",END).strip()
except Exception as exc:
pass
remote_url = format_config_keyword_for_json(remote_url)

if len(remote_url) > 0:
url_array = []
try:
Expand Down Expand Up @@ -2715,31 +2717,46 @@ def check_maxbot_config_unsaved(config_dict):
global txt_resume_keyword_second

try:
date_keyword = txt_date_keyword.get("1.0",END).strip()
date_keyword = format_config_keyword_for_json(date_keyword)

area_keyword = txt_area_keyword.get("1.0",END).strip()
area_keyword = format_config_keyword_for_json(area_keyword)

keyword_exclude = txt_keyword_exclude.get("1.0",END).strip()
keyword_exclude = format_config_keyword_for_json(keyword_exclude)

idle_keyword = txt_idle_keyword.get("1.0",END).strip()
idle_keyword = format_config_keyword_for_json(idle_keyword)

resume_keyword = txt_resume_keyword.get("1.0",END).strip()
resume_keyword = format_config_keyword_for_json(resume_keyword)

idle_keyword_second = txt_idle_keyword_second.get("1.0",END).strip()
idle_keyword_second = format_config_keyword_for_json(idle_keyword_second)

resume_keyword_second = txt_resume_keyword_second.get("1.0",END).strip()
resume_keyword_second = format_config_keyword_for_json(resume_keyword_second)
date_keyword = ""
if 'txt_date_keyword' in globals():
date_keyword = txt_date_keyword.get("1.0",END).strip()
date_keyword = format_config_keyword_for_json(date_keyword)

area_keyword = ""
if 'txt_area_keyword' in globals():
area_keyword = txt_area_keyword.get("1.0",END).strip()
area_keyword = format_config_keyword_for_json(area_keyword)

keyword_exclude = ""
if 'txt_keyword_exclude' in globals():
keyword_exclude = txt_keyword_exclude.get("1.0",END).strip()
keyword_exclude = format_config_keyword_for_json(keyword_exclude)

idle_keyword = ""
if 'txt_idle_keyword' in globals():
idle_keyword = txt_idle_keyword.get("1.0",END).strip()
idle_keyword = format_config_keyword_for_json(idle_keyword)

resume_keyword = ""
if 'txt_resume_keyword' in globals():
resume_keyword = txt_resume_keyword.get("1.0",END).strip()
resume_keyword = format_config_keyword_for_json(resume_keyword)

idle_keyword_second = ""
if 'txt_idle_keyword_second' in globals():
idle_keyword_second = txt_idle_keyword_second.get("1.0",END).strip()
idle_keyword_second = format_config_keyword_for_json(idle_keyword_second)

resume_keyword_second = ""
if 'txt_resume_keyword_second' in globals():
resume_keyword_second = txt_resume_keyword_second.get("1.0",END).strip()
resume_keyword_second = format_config_keyword_for_json(resume_keyword_second)

highlightthickness = 0
if len(combo_ticket_number.get().strip())>0:
if config_dict["ticket_number"] != int(combo_ticket_number.get().strip()):
highlightthickness = 2
if 'combo_ticket_number' in globals():
if len(combo_ticket_number.get().strip())>0:
if config_dict["ticket_number"] != int(combo_ticket_number.get().strip()):
highlightthickness = 2
#combo_ticket_number.config(highlightthickness=highlightthickness, highlightbackground="red")

highlightthickness = 0
Expand Down Expand Up @@ -2777,10 +2794,10 @@ def check_maxbot_config_unsaved(config_dict):
highlightthickness = 2
txt_resume_keyword_second.config(highlightthickness=highlightthickness, highlightbackground="red")
except Exception as exc:
print(exc)
#print(exc)
pass

def resetful_api_timer():
def settgins_gui_timer():
while True:
btn_preview_text_clicked()
preview_question_text_file()
Expand Down Expand Up @@ -2823,17 +2840,19 @@ def update_maxbot_runtime_status():

sync_status_to_extension(not is_paused)

global combo_language
global lbl_maxbot_status_data
try:
global combo_language
new_language = combo_language.get().strip()
language_code=get_language_code_by_name(new_language)
if 'combo_language' in globals():
new_language = combo_language.get().strip()
language_code=get_language_code_by_name(new_language)

global lbl_maxbot_status_data
maxbot_status = translate[language_code]['status_enabled']
if is_paused:
maxbot_status = translate[language_code]['status_paused']

lbl_maxbot_status_data.config(text=maxbot_status)
if 'lbl_maxbot_status_data' in globals():
lbl_maxbot_status_data.config(text=maxbot_status)

global btn_idle
global btn_resume
Expand All @@ -2849,13 +2868,16 @@ def update_maxbot_runtime_status():
last_url = read_last_url_from_file()
if len(last_url) > 60:
last_url=last_url[:60]+"..."
lbl_maxbot_last_url_data.config(text=last_url)
if 'lbl_maxbot_last_url_data' in globals():
lbl_maxbot_last_url_data.config(text=last_url)

global lbl_system_clock_data
system_clock_data = datetime.now()
current_time = system_clock_data.strftime('%H:%M:%S')
#print('Current Time is:', current_time)
lbl_system_clock_data.config(text=current_time)

global lbl_system_clock_data
if 'lbl_system_clock_data' in globals():
lbl_system_clock_data.config(text=current_time)

except Exception as exc:
#print(exc)
Expand Down Expand Up @@ -3383,18 +3405,19 @@ def preview_question_text_file():
question_text = infile.readline()

global txt_question
try:
displayed_question_text = txt_question.get("1.0",END).strip()
if displayed_question_text != question_text:
# start to refresh
txt_question.delete("1.0","end")
if len(question_text) > 0:
txt_question.insert("1.0", question_text)
except Exception as exc:
pass
if 'txt_question' in globals():
try:
displayed_question_text = txt_question.get("1.0",END).strip()
if displayed_question_text != question_text:
# start to refresh
txt_question.delete("1.0","end")
if len(question_text) > 0:
txt_question.insert("1.0", question_text)
except Exception as exc:
pass

if __name__ == "__main__":
threading.Thread(target=resetful_api_timer, daemon=True).start()
threading.Thread(target=settgins_gui_timer, daemon=True).start()
threading.Thread(target=web_server, daemon=True).start()
clean_tmp_file()
main_gui()

0 comments on commit 053d7f1

Please sign in to comment.