fix: 添加 cron_expression_to_human 函数到 utils.py
This commit is contained in:
BIN
__pycache__/config.cpython-312.pyc
Normal file
BIN
__pycache__/config.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/database.cpython-312.pyc
Normal file
BIN
__pycache__/database.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/routes_config.cpython-312.pyc
Normal file
BIN
__pycache__/routes_config.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/routes_cron.cpython-312.pyc
Normal file
BIN
__pycache__/routes_cron.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/routes_email.cpython-312.pyc
Normal file
BIN
__pycache__/routes_email.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/routes_project.cpython-312.pyc
Normal file
BIN
__pycache__/routes_project.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/routes_system.cpython-312.pyc
Normal file
BIN
__pycache__/routes_system.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/templates.cpython-312.pyc
Normal file
BIN
__pycache__/templates.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/utils.cpython-312.pyc
Normal file
BIN
__pycache__/utils.cpython-312.pyc
Normal file
Binary file not shown.
@@ -30314,3 +30314,6 @@ Press CTRL+C to quit
|
|||||||
[2026-06-01 12:29:39] 访问地址: http://localhost:16022
|
[2026-06-01 12:29:39] 访问地址: http://localhost:16022
|
||||||
[2026-06-01 12:29:39] 进程PID: 784244
|
[2026-06-01 12:29:39] 进程PID: 784244
|
||||||
[2026-06-01 12:29:39] ==================================================
|
[2026-06-01 12:29:39] ==================================================
|
||||||
|
[2026-06-01 12:30:38] ⚠️ 进程收到 SIGTERM 信号,即将退出!
|
||||||
|
[2026-06-01 12:31:16] 项目服务管理面板 v3.4.0 初始化完成
|
||||||
|
[2026-06-01 12:31:16] 启动 项目服务管理面板,端口: 16022
|
||||||
|
|||||||
29
utils.py
29
utils.py
@@ -195,6 +195,35 @@ def parse_cron_expression(expr):
|
|||||||
|
|
||||||
return ' '.join(desc) if desc else expr
|
return ' '.join(desc) if desc else expr
|
||||||
|
|
||||||
|
def cron_expression_to_human(expr):
|
||||||
|
"""更友好的人类可读格式"""
|
||||||
|
parts = expr.split()
|
||||||
|
if len(parts) != 5:
|
||||||
|
return expr
|
||||||
|
|
||||||
|
minute, hour, day, month, weekday = parts
|
||||||
|
|
||||||
|
# 特殊模式
|
||||||
|
patterns = [
|
||||||
|
('0 4 * * *', '每天凌晨4点'),
|
||||||
|
('0 0 * * *', '每天午夜0点'),
|
||||||
|
('*/5 * * * *', '每5分钟'),
|
||||||
|
('*/10 * * * *', '每10分钟'),
|
||||||
|
('*/20 * * * *', '每20分钟'),
|
||||||
|
('*/30 * * * *', '每30分钟'),
|
||||||
|
('0 */1 * * *', '每小时'),
|
||||||
|
('0 */2 * * *', '每2小时'),
|
||||||
|
('0 9 * * 1', '每周一9点'),
|
||||||
|
('0 9 * * 1-5', '每周一到五9点'),
|
||||||
|
]
|
||||||
|
|
||||||
|
for pattern, desc in patterns:
|
||||||
|
if expr == pattern:
|
||||||
|
return desc
|
||||||
|
|
||||||
|
# 通用解析
|
||||||
|
return parse_cron_expression(expr)
|
||||||
|
|
||||||
|
|
||||||
def guess_cron_name(command):
|
def guess_cron_name(command):
|
||||||
"""从命令推断任务名称"""
|
"""从命令推断任务名称"""
|
||||||
|
|||||||
Reference in New Issue
Block a user