#!/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())