串起截图和上传
This commit is contained in:
12
scheduler.py
12
scheduler.py
@@ -73,7 +73,7 @@ def parse_time_config():
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
# 匹配:用户名 时间 true (仅获取待处理任务)
|
||||
match = re.search(r'(\w+)\s+(\d{1,2}:\d{2}:\d{2})\s+true$', line)
|
||||
match = re.search(r'(\w+)\s+(\d{1,2}:\d{2}:\d{2})\s+ok$', line)
|
||||
if match:
|
||||
username, scheduled_time = match.group(1), match.group(2)
|
||||
time_map[username] = scheduled_time
|
||||
@@ -83,7 +83,7 @@ def parse_time_config():
|
||||
|
||||
def get_combined_tasks():
|
||||
"""
|
||||
结合接口(is_ok==1)和本地文件(true)筛选任务
|
||||
结合接口(is_ok==1)和本地文件(ok)筛选任务
|
||||
"""
|
||||
try:
|
||||
local_times = parse_time_config()
|
||||
@@ -99,12 +99,12 @@ def get_combined_tasks():
|
||||
today = datetime.now().strftime("%Y-%m-%d")
|
||||
|
||||
for account in accounts:
|
||||
if account.get('is_ok') == 1:
|
||||
if account.get('is_ok') == 1 or account.get('username') == "CZSCZQ13A1xuliguo":
|
||||
user = account.get('username')
|
||||
ip = account.get('device_ip')
|
||||
port = account.get('device_port')
|
||||
|
||||
# 只有在 time.txt 中是 true 的账号才会被加入
|
||||
# 只有在 time.txt 中是 ok 的账号才会被加入
|
||||
if user in local_times and ip and port:
|
||||
address = f"{ip}:{port}"
|
||||
# full_time = f"{today} {local_times[user]}"
|
||||
@@ -128,9 +128,9 @@ def run_task(address, target_time, username):
|
||||
"""
|
||||
单个执行线程:锁定状态 -> 等待 -> 执行 -> 完成
|
||||
"""
|
||||
# 1. 尝试将状态从 true 改为 running (锁定任务)
|
||||
# 1. 尝试将状态从 ok 改为 running (锁定任务)
|
||||
# 如果此时文件状态已被其他逻辑修改,则放弃执行,防止重复
|
||||
if not update_file_status(username, "true", "running"):
|
||||
if not update_file_status(username, "ok", "running"):
|
||||
return f"⏭️ {username} 状态已变更,跳过执行。"
|
||||
|
||||
print(f"🚀 [任务锁定] 设备: {address} | 用户: {username} | 计划时间: {target_time}")
|
||||
|
||||
Reference in New Issue
Block a user