feat: 更新定时任务时间并添加批量处理脚本
- 将定时任务时间从12:00改为14:39 - 新增start_scheduler.bat脚本用于管理进程 - 在config.py中添加messages_reciever配置项 - 优化sendmsg.py代码结构,使用配置项代替硬编码
This commit is contained in:
parent
96e67e8b04
commit
699bac8008
@ -2,5 +2,6 @@ CONFIG = {
|
|||||||
"app_id": "cli_a8de57f7e95f100c",
|
"app_id": "cli_a8de57f7e95f100c",
|
||||||
"app_secret": "jm2nkFnnSNVS3n076VOPfh8k7q0hEKVp",
|
"app_secret": "jm2nkFnnSNVS3n076VOPfh8k7q0hEKVp",
|
||||||
"open_id": "ou_bd33a5f75dd2ccb005a21e4dd01f930c",
|
"open_id": "ou_bd33a5f75dd2ccb005a21e4dd01f930c",
|
||||||
"file_path": "C:\\Users\\22251\\OneDrive\\桌面\\picture\\"
|
"file_path": "C:\\Users\\22251\\OneDrive\\桌面\\picture\\",
|
||||||
|
"messages_reciever": "File Transfer"
|
||||||
}
|
}
|
||||||
@ -9,7 +9,7 @@ def run_sendmsg():
|
|||||||
subprocess.run([sys.executable, script_path])
|
subprocess.run([sys.executable, script_path])
|
||||||
|
|
||||||
# 设置每天12点运行
|
# 设置每天12点运行
|
||||||
schedule.every().day.at("12:00").do(run_sendmsg)
|
schedule.every().day.at("14:39").do(run_sendmsg)
|
||||||
|
|
||||||
print("定时任务已启动,将在每天12:00运行sendmsg.py")
|
print("定时任务已启动,将在每天12:00运行sendmsg.py")
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import subprocess
|
|||||||
import json
|
import json
|
||||||
from config import CONFIG
|
from config import CONFIG
|
||||||
import time
|
import time
|
||||||
|
from config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
today = date.today()
|
today = date.today()
|
||||||
@ -15,19 +16,17 @@ file_path = CONFIG['file_path']+file_name
|
|||||||
try:
|
try:
|
||||||
wx = WeChat()
|
wx = WeChat()
|
||||||
except:
|
except:
|
||||||
#运行send_openmsg.py
|
|
||||||
subprocess.run([sys.executable, 'send_openmsg.py'])
|
subprocess.run([sys.executable, 'send_openmsg.py'])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
msg = 'hello, wxauto!'
|
msg = 'hello, wxauto!'
|
||||||
who = 'File Transfer'
|
who = CONFIG['messages_reciever']
|
||||||
|
|
||||||
if os.path.isfile(file_path):
|
if os.path.isfile(file_path):
|
||||||
error_msg = ""
|
error_msg = ""
|
||||||
else:
|
else:
|
||||||
error_msg = "没找到指定文件"
|
error_msg = "没找到指定文件"
|
||||||
#运行send_filemsg.py
|
|
||||||
subprocess.run([sys.executable, 'send_filemsg.py'])
|
subprocess.run([sys.executable, 'send_filemsg.py'])
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|||||||
9
start_scheduler.bat
Normal file
9
start_scheduler.bat
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
:: 查找并停止所有运行 scheduler.py 的 pythonw 进程
|
||||||
|
for /f "tokens=2" %%a in ('tasklist /fi "imagename eq pythonw.exe" /v ^| findstr "scheduler.py"') do taskkill /F /PID %%a
|
||||||
|
|
||||||
|
:: 等待1秒确保进程完全停止
|
||||||
|
timeout /t 1 /nobreak > nul
|
||||||
|
|
||||||
|
:: 启动新的进程
|
||||||
|
start /min pythonw "%~dp0scheduler.py"
|
||||||
Loading…
x
Reference in New Issue
Block a user