#!/usr/bin/env python3
from os import system, access, R_OK
import sys
system(f"rm split_table.pkl")
system(f"./wecomchan.py 'exec txtable.js'")
system(f"rm test.txt")
for i in range(3): # 尝试三次
system(f"./txtable.js")
if access('test.txt', R_OK):
with open('test.txt', encoding="utf-8") as f:
table = f.read().strip()
print(table)
if table:
system(f"./wecomchan.py 'exec txtable.js succeed'")
break
system(f"./wecomchan.py 'exec txtable.js failed once'")
else:
system(f"./wecomchan.py 'exec txtable.js failed'")
sys.exit(1)
system(f"rm test.txt")
table = table.splitlines()
import datetime
today=datetime.date.today()
formatted_today=today.strftime('%-m月%-d日')
for line in table:
if line.startswith(formatted_today):
print(line)
today_data = line
break
else:
system(f"./wecomchan.py 'txtable.py failed: line.startswith(formatted_today) is False'")
sys.exit(1)
table = table[0:3]
table.append(today_data)
split_table = list()
for line in table:
line = line.split('\t')
split_table.append(line)
# print(line)
split_table[0] = list(filter(None, split_table[0]))
for i in range(1,len(split_table)):
split_table[i] = split_table[i][0:len(split_table[0])]
import pickle
with open("split_table.pkl", "wb") as tf:
pickle.dump(split_table,tf)
进行下午提醒
#!/usr/bin/env python3
from os import system, access, R_OK, chdir
chdir('/home/limour/02')
import sys
system(f"./txtable.py")
if not access('split_table.pkl', R_OK):
sys.exit(1)
import pickle
with open("split_table.pkl", "rb") as tf:
table = pickle.load(tf)
r1 = table[0][2:] #需要填写的人
r4 = table[3][2:] #已经填写的人
r5 = list(r1[x] for x in range(len(r4)) if r4[x] == '') #未填写的人
if r5:
info = '@'+ ' @'.join(r5)
info = f"核酸检测即将结束,请以下同学及时记录自己的检测情况(n={len(r5)}):\n{info}"
else:
info = f"今日核酸/抗原已全部完成!"
system(f"./wecomchan.py '{info}'")
info = info.replace('\n', '\\n')
system(f'''/usr/bin/curl -X POST \\
-H "Content-Type: application/json" \\
-d '{{"msg": "{info}", "toUserName":"filehelper", "token":"a123456"}}' \\
https://limour.top/api/send''')
Comments NOTHING