日你妈

This commit is contained in:
shenjack 2024-11-03 23:51:47 +08:00
parent aa0cae3cdc
commit f57fae691a
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 77 additions and 70 deletions

127
main.py
View File

@ -4,7 +4,6 @@ import random
import hashlib
import datetime
import threading
from typing import Callable
from tkinter import font, ttk, END
import tkinter
@ -23,6 +22,23 @@ from pyglet import media as pyglet_media
logger = config.get_logger("main")
class TimeChecker:
"""用于检查时间, 比如还有多久上课, 还有多久下课等"""
def __init__(self):
self.class_lst = []
self.rest_lst = []
def rest_time(self) -> int:
...
def class_time(self) -> int:
...
TIME_CHCKER = TimeChecker()
def check_pwd(pwd):
global password
password = False
@ -75,7 +91,8 @@ def loading():
image_dict, \
screen_height
fin = False
style = Style(theme="newtheme")
# style = Style(theme="newtheme")
style = Style()
root = style.master
style.configure("TButton")
DraggableWindow(root)
@ -99,12 +116,16 @@ def loading():
root.update_idletasks() # 刷新
root.update()
c.destroy()
fin = True
else:
try:
c.destroy()
except:
pass
k = tkinter.Label(text="本次共清理了\n" + str(file_counter) + "个文件", font=("宋体", 48))
file_counter = 0
k = tkinter.Label(
text="本次共清理了\n" + str(file_counter) + "个文件", font=("宋体", 48)
)
logger.info(f"本次共清理了{file_counter}个文件")
k.place(relx=0.5, rely=0.5, anchor="center")
root.update()
@ -225,7 +246,7 @@ def log(content, rate):
# f.write("日志处理后sha256:" + file_sha256(r"support/journal.log"))
def on_button_click(content, pppp):
def on_button_click(content, do_confirm):
wait_window = tkinter.Toplevel(root)
wait_window.wm_attributes("-topmost", 1)
win_width = 400
@ -246,10 +267,10 @@ def on_button_click(content, pppp):
fg="white",
)
pp.place(rely=0.8, relx=0.3, anchor="center")
if pppp == "pppp":
if do_confirm == "pppp":
ppp = tkinter.Entry(wait_window, width=30, show="*")
ppp.place(relx=0.5, rely=0.6, anchor="center")
pppp = tkinter.Button(
do_confirm = tkinter.Button(
wait_window,
text="忽略",
command=lambda: check_pwd(ppp.get()) and wait_window.destroy(),
@ -258,7 +279,7 @@ def on_button_click(content, pppp):
activebackground="#4472c4",
fg="white",
)
pppp.place(relx=0.6, rely=0.8, anchor="center")
do_confirm.place(relx=0.6, rely=0.8, anchor="center")
wait_window.wait_window()
return True
@ -313,8 +334,6 @@ shouldnot = [
"孙妍",
"王浩楠",
"张一樵",
"李克强",
"蔡奇",
"张建波",
"任杰",
"齐静",
@ -341,56 +360,20 @@ shouldnot = [
"李月",
"付鹏飞",
"王芳",
"习近平",
"隋亚珍",
"特朗普",
"郭晶",
"苏瑶",
"许久辰",
"张三",
"李四",
"王五",
"赵六",
"田七",
"安倍晋三",
"bilibili",
"哔哩哔哩",
]
logging.basicConfig(
filename=os.getcwd() + "/support/journal.log",
filemode="a+",
format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
datefmt="",
level=logging.DEBUG,
)
class PILFilter(logging.Filter):
def filter(self, record):
return record.name != "PIL" or record.levelno > logging.DEBUG
handler = logging.StreamHandler()
handler.addFilter(PILFilter())
# 设置日志级别和处理器
logging.basicConfig(level=logging.DEBUG, handlers=[handler])
def file_hash(file_path: str, hash_method: Callable) -> str:
h = hash_method()
with open(file_path, "rb", encoding="utf-8") as f:
while True:
b = f.read(8192)
if not b:
break
h.update(b)
f.close()
return h.hexdigest()
def file_sha256(file_path: str) -> str:
return file_hash(file_path, hashlib.sha256)
with open(file_path, "rb") as f:
sha256 = hashlib.sha256(f.read()).hexdigest()
return sha256
def check_class():
@ -1530,12 +1513,12 @@ def choice(fromwhere):
except:
pass
if rest() or (not rest() and password):
logger.info('人名单sha256:' + file_sha256(r'support/1.txt'))
logger.info(f'当前有{len(g_list)}')
logger.info("人名单sha256:" + file_sha256(r"support/1.txt"))
logger.info(f"当前有{len(g_list)}")
password = False
except Exception as e:
on_button_click("没有找到人名单文件或因\n" + str(e), "")
logger.info(f'没有找到人名单文件或因{e}')
logger.info(f"没有找到人名单文件或因{e}")
schedule("fromchoice")
root.quit()
try:
@ -1639,11 +1622,11 @@ def choice(fromwhere):
)
else:
chosed.append(r)
log("本次抽中" + r, "info")
logger.info(f"本次抽中{r}")
with open("support/record.txt", "a+") as p:
p.write(r + "\n")
p.close()
log("操作后sha256:" + file_sha256(r"support/record.txt"), "info")
logger.info("操作后sha256:" + file_sha256(r"support/record.txt"))
inf = tkinter.Label(
text=str(len(chosed)) + "/" + info + "。剩余5人时将开启新一轮。",
font=("微软雅黑", 10),
@ -1691,7 +1674,9 @@ def choice(fromwhere):
file_counter.destroy()
except:
pass
file_counter = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
file_counter = tkinter.Label(
text=g_list[r], width=30, font=("华文行楷", 72)
)
file_counter.place(relx=0.5, rely=0.4, anchor="center")
root.update()
time.sleep(0.01)
@ -1700,7 +1685,9 @@ def choice(fromwhere):
file_counter.destroy()
except:
pass
file_counter = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
file_counter = tkinter.Label(
text=g_list[r], width=30, font=("华文行楷", 72)
)
file_counter.place(relx=0.5, rely=0.4, anchor="center")
root.update()
time.sleep(0.01)
@ -1846,7 +1833,7 @@ def schedule(fr):
listindes = sheet.col_values(index) # 获取age列的所有内容
except:
on_button_click("请确认课程表文件\n存在且格式正确", "")
log("课程表文件不存在", "error")
logger.error("课程表文件不存在")
root.quit()
# 遍历该列所有的内容
style.configure("TButton", font=("华文行楷", 40))
@ -1959,7 +1946,7 @@ def schedule(fr):
root.wm_attributes("-topmost", 0)
def check_resttime():
def check_resttime() -> int:
global zhou, d
try:
excel = xlrd.open_workbook("support/时刻表.xls") # 打开excel文件
@ -1985,14 +1972,10 @@ def check_resttime():
return 2400
def count():
time.sleep(10)
def bsy(fro=None):
global top
if fro is None:
time.sleep(10)
global top, btn
# if fro is None:
# time.sleep(10)
while isinstance(check_class(), tuple):
try:
btn.config(text=check_class()[0][0] + "" + check_class()[1][0])
@ -2012,7 +1995,7 @@ def bsy(fro=None):
def clean():
...
# global fin, file_counter, ll, lose
global fin, file_counter, ll, lose
# ll = "正在清理文件"
# fin = False
# file_counter = 0
@ -2053,7 +2036,7 @@ def clean():
# file_counter = file_counter + 1
# else:
# ll = filename + "未到过期时间"
# ll = "正在检查程序组件"
ll = "正在检查程序组件"
# x = os.listdir("support")
# list = [
# "temp.txt",
@ -2065,7 +2048,7 @@ def clean():
# "record.txt",
# "config.ini",
# ]
# lose = []
lose = []
# for y in list:
# ll = "检查" + y
# if y in x:
@ -2073,7 +2056,7 @@ def clean():
# else:
# ll = "缺少" + y
# lose.append(y)
# fin = True
fin = True
speed = 50
@ -2087,6 +2070,10 @@ t2 = threading.Thread(
) # 定义线程t2线程任务为调用task2函数task2函数无参数
t3 = threading.Thread(target=bsy, name="bsy")
t1.start() # 开始运行t1线程
t2.start() # 开始运行t2线程
time.sleep(5)
t3.start()
t2.start() # 开始运行t2线程
# t3.start()
on_button_click(
"人名单文件的sha256值\n与上次不一致。\n请确认人名单是否被篡改。\n按确定以继续。",
"",
)

View File

@ -1,3 +1,9 @@
时间表
08:00-08:40
08:55-09:35
09:35-09:35
10:05-10:45
10:45-10:45
11:00-11:40
11:40-11:40
13:00-13:40
@ -6,3 +12,17 @@
14:50-15:30
15:45-16:25
16:35-17:15
时刻表
07:00-08:40
08:40-09:35
09:35-09:35
09:35-10:45
10:45-10:45
10:45-11:40
11:40-11:40
11:40-13:40
13:40-13:40
13:40-14:35
14:35-15:30
15:30-16:25
16:25-17:15