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