真是一场酣畅淋漓的吃屎啊
This commit is contained in:
parent
46983d093e
commit
aa0cae3cdc
226
main.py
226
main.py
@ -1,20 +1,28 @@
|
|||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
import hashlib
|
||||||
|
import datetime
|
||||||
import threading
|
import threading
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from pyglet import media as pyglet_media
|
|
||||||
|
|
||||||
# from tkinter import *
|
|
||||||
from tkinter import font, ttk, END
|
from tkinter import font, ttk, END
|
||||||
import tkinter
|
import tkinter
|
||||||
import tkinter.messagebox
|
import tkinter.messagebox
|
||||||
|
|
||||||
import random, tkinter, time, xlrd, datetime, logging, hashlib, shutil, pyperclip, requests
|
import xlrd
|
||||||
from ttkbootstrap import Style
|
import requests
|
||||||
|
import pyperclip
|
||||||
|
|
||||||
|
from lib_not_dr.loggers import config
|
||||||
from docx import Document
|
from docx import Document
|
||||||
from PIL import Image, ImageTk
|
from PIL import Image, ImageTk
|
||||||
|
from ttkbootstrap import Style
|
||||||
|
from pyglet import media as pyglet_media
|
||||||
|
|
||||||
|
|
||||||
|
logger = config.get_logger("main")
|
||||||
|
|
||||||
def check_pwd(pwd):
|
def check_pwd(pwd):
|
||||||
global password
|
global password
|
||||||
password = False
|
password = False
|
||||||
@ -37,7 +45,7 @@ def check_pwd(pwd):
|
|||||||
def loading():
|
def loading():
|
||||||
global \
|
global \
|
||||||
fin, \
|
fin, \
|
||||||
a, \
|
file_counter, \
|
||||||
root, \
|
root, \
|
||||||
screen_width, \
|
screen_width, \
|
||||||
ll, \
|
ll, \
|
||||||
@ -83,7 +91,7 @@ def loading():
|
|||||||
root.geometry("{}x{}+{}+{}".format(win_width, win_height, win_x, win_y))
|
root.geometry("{}x{}+{}+{}".format(win_width, win_height, win_x, win_y))
|
||||||
root.update()
|
root.update()
|
||||||
root.update()
|
root.update()
|
||||||
log("正在清理文件", "info")
|
logger.info("正在清理文件")
|
||||||
while not fin:
|
while not fin:
|
||||||
c = tkinter.Label(text=ll, font=("宋体", 10))
|
c = tkinter.Label(text=ll, font=("宋体", 10))
|
||||||
c.place(relx=0.5, rely=0.8, anchor="center")
|
c.place(relx=0.5, rely=0.8, anchor="center")
|
||||||
@ -96,8 +104,8 @@ def loading():
|
|||||||
c.destroy()
|
c.destroy()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
k = tkinter.Label(text="本次共清理了\n" + str(a) + "个文件", font=("宋体", 48))
|
k = tkinter.Label(text="本次共清理了\n" + str(file_counter) + "个文件", font=("宋体", 48))
|
||||||
log("本次共清理了" + str(a) + "个文件", "info")
|
logger.info(f"本次共清理了{file_counter}个文件")
|
||||||
k.place(relx=0.5, rely=0.5, anchor="center")
|
k.place(relx=0.5, rely=0.5, anchor="center")
|
||||||
root.update()
|
root.update()
|
||||||
root.after(1500)
|
root.after(1500)
|
||||||
@ -169,7 +177,7 @@ def loading():
|
|||||||
for image_file in subjects:
|
for image_file in subjects:
|
||||||
try:
|
try:
|
||||||
subphoto = Image.open("support/" + image_file + ".png")
|
subphoto = Image.open("support/" + image_file + ".png")
|
||||||
except:
|
except FileNotFoundError:
|
||||||
try:
|
try:
|
||||||
file = requests.get(
|
file = requests.get(
|
||||||
"http://shenjack.top:5100/people/what/raw/branch/main/"
|
"http://shenjack.top:5100/people/what/raw/branch/main/"
|
||||||
@ -200,20 +208,21 @@ def loading():
|
|||||||
|
|
||||||
|
|
||||||
def log(content, rate):
|
def log(content, rate):
|
||||||
if rate == "info":
|
...
|
||||||
logging.info(content)
|
# if rate == "info":
|
||||||
elif rate == "warning":
|
# logging.info(content)
|
||||||
logging.warning(content)
|
# elif rate == "warning":
|
||||||
elif rate == "error":
|
# logging.warning(content)
|
||||||
logging.error(content)
|
# elif rate == "error":
|
||||||
else:
|
# logging.error(content)
|
||||||
logging.error("日志评级不正确,记录内容为:" + content)
|
# else:
|
||||||
with open("support/config.ini", "a+", encoding="utf-8") as f:
|
# logging.error("日志评级不正确,记录内容为:" + content)
|
||||||
a = f.readlines()
|
# with open("support/config.ini", "a+", encoding="utf-8") as f:
|
||||||
for x in range(len(a)):
|
# a = f.readlines()
|
||||||
if "日志处理后sha256" in a[x]:
|
# for x in range(len(a)):
|
||||||
del f.readlines()[x]
|
# if "日志处理后sha256" in a[x]:
|
||||||
f.write("日志处理后sha256:" + file_sha256(r"support/journal.log"))
|
# del f.readlines()[x]
|
||||||
|
# f.write("日志处理后sha256:" + file_sha256(r"support/journal.log"))
|
||||||
|
|
||||||
|
|
||||||
def on_button_click(content, pppp):
|
def on_button_click(content, pppp):
|
||||||
@ -389,7 +398,7 @@ def check_class():
|
|||||||
try:
|
try:
|
||||||
excel = xlrd.open_workbook("support/时刻表.xls") # 打开excel文件
|
excel = xlrd.open_workbook("support/时刻表.xls") # 打开excel文件
|
||||||
sheet = excel.sheet_by_index(0) # 获取工作薄
|
sheet = excel.sheet_by_index(0) # 获取工作薄
|
||||||
rows: g_list = sheet.row_values(0) # 获取第一行的表头内容
|
rows: list = sheet.row_values(0) # 获取第一行的表头内容
|
||||||
index = rows.index("时刻表") # 获取age列所在的列数: 1,也可以换成"password"
|
index = rows.index("时刻表") # 获取age列所在的列数: 1,也可以换成"password"
|
||||||
listindes = sheet.col_values(index) # 获取age列的所有内容
|
listindes = sheet.col_values(index) # 获取age列的所有内容
|
||||||
for x in range(1, len(listindes)):
|
for x in range(1, len(listindes)):
|
||||||
@ -404,7 +413,7 @@ def check_class():
|
|||||||
if start_time < now_time < end_time:
|
if start_time < now_time < end_time:
|
||||||
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
||||||
sheet = excel.sheet_by_index(0) # 获取工作薄
|
sheet = excel.sheet_by_index(0) # 获取工作薄
|
||||||
rows: g_list = sheet.row_values(0) # 获取第一行的表头内容
|
rows: list = sheet.row_values(0) # 获取第一行的表头内容
|
||||||
index = rows.index(
|
index = rows.index(
|
||||||
zhou[d.weekday()]
|
zhou[d.weekday()]
|
||||||
) # 获取age列所在的列数: 1,也可以换成"password"
|
) # 获取age列所在的列数: 1,也可以换成"password"
|
||||||
@ -430,7 +439,7 @@ def rest():
|
|||||||
try:
|
try:
|
||||||
excel = xlrd.open_workbook("support/时间表.xls") # 打开excel文件
|
excel = xlrd.open_workbook("support/时间表.xls") # 打开excel文件
|
||||||
sheet = excel.sheet_by_index(0) # 获取工作薄
|
sheet = excel.sheet_by_index(0) # 获取工作薄
|
||||||
rows: g_list = sheet.row_values(0) # 获取第一行的表头内容
|
rows: list = sheet.row_values(0) # 获取第一行的表头内容
|
||||||
index = rows.index("时间表") # 获取age列所在的列数: 1,也可以换成"password"
|
index = rows.index("时间表") # 获取age列所在的列数: 1,也可以换成"password"
|
||||||
listindes = sheet.col_values(index) # 获取age列的所有内容
|
listindes = sheet.col_values(index) # 获取age列的所有内容
|
||||||
for x in range(1, len(listindes)):
|
for x in range(1, len(listindes)):
|
||||||
@ -801,14 +810,14 @@ def homework(pas=None, window=None, line=9999):
|
|||||||
try:
|
try:
|
||||||
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
||||||
sheet = excel.sheet_by_index(0) # 获取工作薄
|
sheet = excel.sheet_by_index(0) # 获取工作薄
|
||||||
rows: g_list = sheet.row_values(0) # 获取第一行的表头内容
|
rows: list = sheet.row_values(0) # 获取第一行的表头内容
|
||||||
index = rows.index(
|
index = rows.index(
|
||||||
zhou[d.weekday()]
|
zhou[d.weekday()]
|
||||||
) # 获取age列所在的列数: 1,也可以换成"password"
|
) # 获取age列所在的列数: 1,也可以换成"password"
|
||||||
listindes = sheet.col_values(index) # 获取age列的所有内容
|
listindes = sheet.col_values(index) # 获取age列的所有内容
|
||||||
except:
|
except:
|
||||||
listindes = "没有找到课程表文件"
|
listindes = "没有找到课程表文件"
|
||||||
log("课程表文件不存在", "error")
|
logger.error("课程表文件不存在")
|
||||||
# 遍历该列所有的内容
|
# 遍历该列所有的内容
|
||||||
zxs = tkinter.Label(right_area, text="曾", font=("华文行楷", 40))
|
zxs = tkinter.Label(right_area, text="曾", font=("华文行楷", 40))
|
||||||
zxs.grid(column=0, row=0)
|
zxs.grid(column=0, row=0)
|
||||||
@ -1516,17 +1525,17 @@ def choice(fromwhere):
|
|||||||
else:
|
else:
|
||||||
password = True
|
password = True
|
||||||
except:
|
except:
|
||||||
log("人名单sha256:" + file_sha256(r"support/1.txt"), "info")
|
logger.info(f'人名单sha256: {file_sha256(r"support/1.txt")}')
|
||||||
password = True
|
password = True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if (rest()) or (not rest() and password):
|
if rest() or (not rest() and password):
|
||||||
log("人名单sha256:" + file_sha256(r"support/1.txt"), "info")
|
logger.info('人名单sha256:' + file_sha256(r'support/1.txt'))
|
||||||
log("当前有" + str(len(g_list)) + "人", "info")
|
logger.info(f'当前有{len(g_list)}人')
|
||||||
password = False
|
password = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
on_button_click("没有找到人名单文件或因\n" + str(e), "")
|
on_button_click("没有找到人名单文件或因\n" + str(e), "")
|
||||||
log("人名单文件不存在", "info")
|
logger.info(f'没有找到人名单文件或因{e}')
|
||||||
schedule("fromchoice")
|
schedule("fromchoice")
|
||||||
root.quit()
|
root.quit()
|
||||||
try:
|
try:
|
||||||
@ -1550,7 +1559,7 @@ def choice(fromwhere):
|
|||||||
else:
|
else:
|
||||||
password = True
|
password = True
|
||||||
if (rest()) or (not rest() and password):
|
if (rest()) or (not rest() and password):
|
||||||
log("操作后sha256:" + file_sha256(r"support/record.txt"), "info")
|
logger.info(f'操作后sha256:{file_sha256(r"support/record.txt")}')
|
||||||
password = False
|
password = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -1578,7 +1587,6 @@ def choice(fromwhere):
|
|||||||
else:
|
else:
|
||||||
password = True
|
password = True
|
||||||
if (rest()) or (not rest() and password):
|
if (rest()) or (not rest() and password):
|
||||||
log("", "info")
|
|
||||||
password = False
|
password = False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@ -1612,7 +1620,7 @@ def choice(fromwhere):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def stop(r):
|
def stop(r):
|
||||||
global flag, status, g_list, info, a, chosed, inf
|
global flag, status, g_list, info, file_counter, chosed, inf
|
||||||
flag = True
|
flag = True
|
||||||
status = "开始"
|
status = "开始"
|
||||||
if not rest():
|
if not rest():
|
||||||
@ -1653,7 +1661,7 @@ def choice(fromwhere):
|
|||||||
start.place(relx=0.5, rely=1, anchor="s")
|
start.place(relx=0.5, rely=1, anchor="s")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global flag, root, g_list, status, info, a, chosed, inf
|
global flag, root, g_list, status, info, file_counter, chosed, inf
|
||||||
try:
|
try:
|
||||||
inf.destroy()
|
inf.destroy()
|
||||||
except:
|
except:
|
||||||
@ -1677,23 +1685,23 @@ def choice(fromwhere):
|
|||||||
with open("support/record.txt", "a+") as g:
|
with open("support/record.txt", "a+") as g:
|
||||||
g.truncate(0)
|
g.truncate(0)
|
||||||
g.close()
|
g.close()
|
||||||
log("操作后sha256:" + file_sha256(r"support/record.txt"), "info")
|
logger.info("操作后sha256:", file_sha256(r"support/record.txt"))
|
||||||
if (g_list[r] not in chosed) and (int(nolis.get()) == 0):
|
if (g_list[r] not in chosed) and (int(nolis.get()) == 0):
|
||||||
try:
|
try:
|
||||||
a.destroy()
|
file_counter.destroy()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
a = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
|
file_counter = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
|
||||||
a.place(relx=0.5, rely=0.4, anchor="center")
|
file_counter.place(relx=0.5, rely=0.4, anchor="center")
|
||||||
root.update()
|
root.update()
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
elif int(nolis.get()) == 1:
|
elif int(nolis.get()) == 1:
|
||||||
try:
|
try:
|
||||||
a.destroy()
|
file_counter.destroy()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
a = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
|
file_counter = tkinter.Label(text=g_list[r], width=30, font=("华文行楷", 72))
|
||||||
a.place(relx=0.5, rely=0.4, anchor="center")
|
file_counter.place(relx=0.5, rely=0.4, anchor="center")
|
||||||
root.update()
|
root.update()
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
||||||
@ -1782,7 +1790,6 @@ def schedule(fr):
|
|||||||
canceltopping, \
|
canceltopping, \
|
||||||
photo, \
|
photo, \
|
||||||
lose, \
|
lose, \
|
||||||
hh, \
|
|
||||||
h, \
|
h, \
|
||||||
no, \
|
no, \
|
||||||
z, \
|
z, \
|
||||||
@ -1832,7 +1839,7 @@ def schedule(fr):
|
|||||||
try:
|
try:
|
||||||
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
excel = xlrd.open_workbook("support/课程表.xls") # 打开excel文件
|
||||||
sheet = excel.sheet_by_index(0) # 获取工作薄
|
sheet = excel.sheet_by_index(0) # 获取工作薄
|
||||||
rows: g_list = sheet.row_values(0) # 获取第一行的表头内容
|
rows: list = sheet.row_values(0) # 获取第一行的表头内容
|
||||||
index = rows.index(
|
index = rows.index(
|
||||||
zhou[d.weekday()]
|
zhou[d.weekday()]
|
||||||
) # 获取age列所在的列数: 1,也可以换成"password"
|
) # 获取age列所在的列数: 1,也可以换成"password"
|
||||||
@ -2004,68 +2011,69 @@ def bsy(fro=None):
|
|||||||
|
|
||||||
|
|
||||||
def clean():
|
def clean():
|
||||||
global fin, a, ll, lose
|
...
|
||||||
ll = "正在清理文件"
|
# global fin, file_counter, ll, lose
|
||||||
fin = False
|
# ll = "正在清理文件"
|
||||||
a = 0
|
# fin = False
|
||||||
current_dir = os.getcwd()
|
# file_counter = 0
|
||||||
uncommon_dir = os.path.join(current_dir, "不常用的文件")
|
# current_dir = os.getcwd()
|
||||||
if not os.path.exists(uncommon_dir):
|
# uncommon_dir = os.path.join(current_dir, "不常用的文件")
|
||||||
os.mkdir(uncommon_dir)
|
# if not os.path.exists(uncommon_dir):
|
||||||
one_week_ago = datetime.datetime.now() - datetime.timedelta(days=7)
|
# os.mkdir(uncommon_dir)
|
||||||
for filename in os.listdir(current_dir):
|
# one_week_ago = datetime.datetime.now() - datetime.timedelta(days=7)
|
||||||
filepath = os.path.join(current_dir, filename)
|
# for filename in os.listdir(current_dir):
|
||||||
ll = "检查" + filepath
|
# filepath = os.path.join(current_dir, filename)
|
||||||
ll = filename
|
# ll = "检查" + filepath
|
||||||
if filename == "不常用的文件":
|
# ll = filename
|
||||||
ll = "跳过" + filename
|
# if filename == "不常用的文件":
|
||||||
elif (
|
# ll = "跳过" + filename
|
||||||
filename == "文件归档.py"
|
# elif (
|
||||||
or filename == "loading.gif"
|
# filename == "文件归档.py"
|
||||||
or filename == "课程表.xls"
|
# or filename == "loading.gif"
|
||||||
or filename == "时间表.xls"
|
# or filename == "课程表.xls"
|
||||||
or filename == "1.txt"
|
# or filename == "时间表.xls"
|
||||||
or filename == "journal.log"
|
# or filename == "1.txt"
|
||||||
or filename == "record.txt"
|
# or filename == "journal.log"
|
||||||
or os.path.isdir(filepath) == "support"
|
# or filename == "record.txt"
|
||||||
or filename.endswith(".exe")
|
# or os.path.isdir(filepath) == "support"
|
||||||
or filename.endswith(".lnk")
|
# or filename.endswith(".exe")
|
||||||
or filename.endswith(".ini")
|
# or filename.endswith(".lnk")
|
||||||
or ("nodelete" in filename)
|
# or filename.endswith(".ini")
|
||||||
or ("support" in filename)
|
# or ("nodelete" in filename)
|
||||||
):
|
# or ("support" in filename)
|
||||||
ll = "跳过" + filename
|
# ):
|
||||||
elif os.path.getmtime(filepath) < one_week_ago.timestamp():
|
# ll = "跳过" + filename
|
||||||
ll = "移动" + filename
|
# elif os.path.getmtime(filepath) < one_week_ago.timestamp():
|
||||||
try:
|
# ll = "移动" + filename
|
||||||
shutil.move(filepath, os.path.join(uncommon_dir, filename))
|
# try:
|
||||||
log("移动了" + filename, "info")
|
# shutil.move(filepath, os.path.join(uncommon_dir, filename))
|
||||||
except Exception as e:
|
# log("移动了" + filename, "info")
|
||||||
log("移动" + str(filename) + "失败,因为" + str(e), "warning")
|
# except Exception as e:
|
||||||
a = a + 1
|
# log("移动" + str(filename) + "失败,因为" + str(e), "warning")
|
||||||
else:
|
# file_counter = file_counter + 1
|
||||||
ll = filename + "未到过期时间"
|
# else:
|
||||||
ll = "正在检查程序组件"
|
# ll = filename + "未到过期时间"
|
||||||
x = os.listdir("support")
|
# ll = "正在检查程序组件"
|
||||||
list = [
|
# x = os.listdir("support")
|
||||||
"temp.txt",
|
# list = [
|
||||||
"课程表.xls",
|
# "temp.txt",
|
||||||
"时间表.xls",
|
# "课程表.xls",
|
||||||
"时刻表.xls",
|
# "时间表.xls",
|
||||||
"1.txt",
|
# "时刻表.xls",
|
||||||
"journal.log",
|
# "1.txt",
|
||||||
"record.txt",
|
# "journal.log",
|
||||||
"config.ini",
|
# "record.txt",
|
||||||
]
|
# "config.ini",
|
||||||
lose = []
|
# ]
|
||||||
for y in list:
|
# lose = []
|
||||||
ll = "检查" + y
|
# for y in list:
|
||||||
if y in x:
|
# ll = "检查" + y
|
||||||
ll = "存在" + y
|
# if y in x:
|
||||||
else:
|
# ll = "存在" + y
|
||||||
ll = "缺少" + y
|
# else:
|
||||||
lose.append(y)
|
# ll = "缺少" + y
|
||||||
fin = True
|
# lose.append(y)
|
||||||
|
# fin = True
|
||||||
|
|
||||||
|
|
||||||
speed = 50
|
speed = 50
|
||||||
|
8
support/时间表.txt
Normal file
8
support/时间表.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
11:00-11:40
|
||||||
|
11:40-11:40
|
||||||
|
13:00-13:40
|
||||||
|
13:40-13:40
|
||||||
|
13:55-14:35
|
||||||
|
14:50-15:30
|
||||||
|
15:45-16:25
|
||||||
|
16:35-17:15
|
Loading…
Reference in New Issue
Block a user