-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (62 loc) · 2.25 KB
/
main.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import sys
import os
from pathlib import Path
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import Qt
from dotenv import load_dotenv
import wmi
# プロジェクトルートとsrcディレクトリをPythonパスに追加
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
# DPI設定を調整
if hasattr(Qt, 'AA_EnableHighDpiScaling'):
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps, True)
# ロギングの設定
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('app.log', encoding='utf-8')
]
)
# 必要なモジュールのインポート
from src.gui.main_window import MainWindow
from src.agent.autonomous_agent import AutonomousAgent
from src.agent.command_interpreter import CommandInterpreter
from src.db.models import DatabaseManager
def main():
try:
load_dotenv()
# データベースの初期化
db_manager = DatabaseManager()
db_manager.initialize_database()
# アプリケーションの初期化
app = QApplication(sys.argv)
# エージェントとインタープリタの初期化
agent = AutonomousAgent(db_manager.get_logger())
interpreter = CommandInterpreter()
# システム情報の初期化
try:
system = wmi.WMI()
except Exception as e:
logging.error(f"WMI初期化エラー: {e}")
system = None
# メインウィンドウの作成と表示
window = MainWindow(agent, interpreter, system)
window.show()
logging.info("ウィンドウを表示しました")
# アプリケーションの実行
return app.exec()
except Exception as e:
logging.error(f"アプリケーション起動エラー: {e}")
import traceback
logging.error(traceback.format_exc())
return 1
if __name__ == '__main__':
sys.exit(main())