office_helper_main.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import argparse
  2. import os.path
  3. import threading
  4. from core.api_app import app, start_flask
  5. from core.monitor_file import start_watchdog
  6. from tools.serve_client import ServerClient
  7. from tools.logger_handle import logger
  8. # 初始化 Flask 应用
  9. # 初始化桌面通知工具
  10. # 存储文档内容和推荐内容
  11. current_text = ""
  12. recommendation = "这是默认推荐内容"
  13. # 启动所有后台服务
  14. def start_all_services(serve_client, work_path):
  15. # 启动 Flask 服务
  16. threading.Thread(target=start_flask, args=[serve_client, work_path], daemon=True).start()
  17. # 启动文件监控
  18. # threading.Thread(target=start_watchdog, args=[serve_client, work_path], daemon=True).start()
  19. # 启动文档内容检查
  20. # threading.Thread(target=check_for_changes, daemon=True).start()
  21. logger.info('server running')
  22. while True:
  23. a = 0
  24. if __name__ == "__main__":
  25. parser = argparse.ArgumentParser(description='办公助手')
  26. parser.add_argument('--worker_path', type=str, required=True, help='文件下载目录。')
  27. parser.add_argument('--username', type=str, required=True, help='用户名')
  28. parser.add_argument('--password', type=str, required=True, help='密码')
  29. parser.add_argument('--server', type=str, required=True, help='密码')
  30. args = parser.parse_args()
  31. client = ServerClient(args.server, args.username, args.password)
  32. if not os.path.exists(os.path.join(args.worker_path, args.username)):
  33. os.makedirs(os.path.join(args.worker_path, args.username))
  34. start_all_services(client, os.path.join(args.worker_path, args.username))