Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
IRON xiang
mail_manager_xjc
Commits
ee8204ce
Commit
ee8204ce
authored
2 months ago
by
IRON xiang
Browse files
Options
Download
Email Patches
Plain Diff
添加时间区间判定函数 should_script_run
parent
81bcadfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
mail_manager/mail_manager.py
mail_manager/mail_manager.py
+6
-5
No files found.
mail_manager/mail_manager.py
View file @
ee8204ce
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment