-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (36 loc) · 1.19 KB
/
main.py
File metadata and controls
42 lines (36 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
import os
from utils.logger import init_logger
from config.config_manager import load_config
from scheduler.task_scheduler import setup_scheduler
from gui.main_window import start_gui
def main():
# 初始化日志
try:
log_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logs')
# 确保日志目录存在
if not os.path.exists(log_dir):
try:
os.makedirs(log_dir)
except Exception:
# 如果无法创建日志目录,使用当前目录
log_dir = '.'
# 启动时清空日志文件
init_logger(log_dir, clean_logs=True)
except Exception as e:
print(f"初始化日志时出错: {e}")
# 如果初始化日志失败,继续运行但不记录日志
pass
# 加载配置
config = load_config()
# 创建调度器
scheduler = setup_scheduler(config)
# 启动GUI(将调度器传递给GUI)
start_gui(config, scheduler)
# GUI关闭后,关闭调度器
scheduler.shutdown()
if __name__ == "__main__":
try:
main()
except Exception as e:
print(f"程序发生异常: {e}")