poc/project/llmclipboard/run_app.py
2025-03-02 18:56:33 +08:00

46 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
LLMClipboard 启动脚本
用于启动LLMClipboard应用程序避免相对导入问题
"""
import sys
import os
import logging
# 添加当前目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# 设置基本日志配置
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
def main():
"""启动应用程序的主函数"""
try:
# 导入应用程序模块
from llmclipboard.app import main as app_main
# 运行应用程序
return app_main()
except Exception as e:
logging.error(f"启动应用程序时出错: {e}", exc_info=True)
# 在打包环境中,确保错误信息被记录
if getattr(sys, 'frozen', False):
import traceback
import time
error_log_path = os.path.join(os.path.dirname(sys.executable), 'error_log.txt')
with open(error_log_path, 'a', encoding='utf-8') as f:
f.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} - Error: {str(e)}\n")
traceback.print_exc(file=f)
return 1
if __name__ == "__main__":
sys.exit(main())