Commit ee8204ce authored by IRON xiang's avatar IRON xiang
Browse files

添加时间区间判定函数 should_script_run

parent 81bcadfb
......@@ -6,7 +6,7 @@ import time
import traceback
import sys
import datetime
sys.path.append("..") # 添加上级目录
from source.walle import Walle
from loguru import logger as LOG
......@@ -19,7 +19,7 @@ import re
def should_script_run():
"""判断当前时间是否在 00:00 至 08:00 之间,若在则返回 False(不运行脚本)"""
current_time = datetime.now().time()
current_time = datetime.datetime.now().time()
start = datetime.time(0, 0) # 00:00(24:00)
end = datetime.time(8, 0) # 08:00
......@@ -41,7 +41,7 @@ server = zmail.server(
)
dingR2t = dingR2t()
from datetime import datetime
def move_file(source_path, target_dir):
......@@ -65,7 +65,7 @@ def move_file(source_path, target_dir):
# 获取当前时间并格式化
def current_time():
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
class MyError(Exception):
......@@ -173,7 +173,8 @@ while True:
# zmail.show(mail)
LOG.info('sleep 1800s')
t = 1800 + random.random() * 500
# t = 1800 + random.random() * 500
t = 20
time.sleep(t) # 每5分钟检查一次
if not should_script_run():
continue
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment