feat: Enhance WebSocket error handling and update software configuration paths

This commit is contained in:
sladro 2026-03-02 16:29:38 +08:00
parent 77500b4708
commit 5cf541aa21
2 changed files with 127 additions and 110 deletions

View File

@ -7,7 +7,7 @@ import json
import logging
import uuid
from fastapi import APIRouter, WebSocket, WebSocketDisconnect, Depends, Query
from fastapi import APIRouter, WebSocket, WebSocketDisconnect, Depends, Query, HTTPException
from app.core.websocket_manager import websocket_manager, MessageType
logger = logging.getLogger(__name__)
@ -549,10 +549,28 @@ async def handle_client_message(message: dict, client_id: str, user_id: str):
"timestamp": websocket_manager._get_timestamp()
}, client_id)
except Exception as e:
except HTTPException as e:
detail = str(e.detail) if e.detail is not None else "未知错误"
await websocket_manager.send_personal_message({
"type": MessageType.ERROR,
"message": f"获取文件列表失败: {str(e)}",
"message": f"获取文件列表失败: {detail}",
"data": {
"error": detail,
"detail": detail,
"status_code": e.status_code
},
"timestamp": websocket_manager._get_timestamp()
}, client_id)
except Exception as e:
error_text = str(e) if str(e).strip() else "未知错误"
await websocket_manager.send_personal_message({
"type": MessageType.ERROR,
"message": f"获取文件列表失败: {error_text}",
"data": {
"error": error_text,
"detail": error_text
},
"timestamp": websocket_manager._get_timestamp()
}, client_id)

View File

@ -1,129 +1,128 @@
file_storage:
cad_files_path: "C:\\Users\\sladr\\Documents\\闄€铻烘车PROE璁捐\\"
file_storage:
cad_files_path: C:\Users\sladr\Documents\
file_extensions:
creo:
- .prt
- .asm
- .drw
- .prt
- .asm
- .drw
pdms:
- .rvm
- .dri
- .rvm
- .dri
revit:
- .rvt
- .rfa
- .rte
- .rvt
- .rfa
- .rte
plugins:
creo:
base_url: http://localhost:12345
callback_timeout_sec: 60
callback_token: creo-callback-token
max_retries: 1
request_timeout_sec: 10
retry_backoff_sec:
- 1
- 3
submit_path: /api/plugin/tasks
tasks:
close_model:
body_mode: creo_close_model
completion_mode: sync
path: /api/model/close
open_model:
body_mode: file_path
path: /api/model/open
shell_analysis:
body_mode: task_params_only
path: /api/analysis/shell-analysis
shrinkwrap_shell:
body_mode: task_params_only
path: /api/creo/shrinkwrap/shell
pdms:
base_url: http://localhost:9001
callback_timeout_sec: 60
callback_token: pdms-callback-token
max_retries: 1
request_timeout_sec: 10
retry_backoff_sec:
- 1
- 3
submit_path: /api/plugin/tasks
tasks:
close_project:
body_mode: task_params_only
path: /api/project/close
open_mdb:
body_mode: project_open
path: /api/mdb/open
open_project:
body_mode: project_open
path: /api/project/open
shrinkwrap_model:
body_mode: task_params_only
path: /api/model/shrinkwrap
simplify_model:
body_mode: task_params_only
path: /api/model/simplify
revit:
base_url: http://localhost:9000
callback_timeout_sec: 60
callback_token: revit-callback-token
max_retries: 1
request_timeout_sec: 10
retry_backoff_sec:
- 1
- 3
submit_path: /api/plugin/tasks
tasks:
close_model:
body_mode: empty
completion_mode: sync
path: /api/close
open_model:
body_mode: file_path
path: /api/open
shell_analyze:
body_mode: task_params_only
path: /api/shell/analyze
shell_execute:
body_mode: task_params_only
path: /api/shell/execute
routing:
extension_to_software:
.asm: creo
.dri: pdms
.drw: creo
.prt: creo
.rfa: revit
.rte: revit
.rvm: pdms
.rvt: revit
software:
creo:
check_process_name:
- xtop.exe
- pro_comm_msg.exe
executable_path: "C:\\Program Files\\PTC\\Creo 5.0.0.0\\Parametric\\bin\\parametric.exe"
- xtop.exe
- pro_comm_msg.exe
executable_path: C:\Program Files\PTC\Creo 5.0.0.0\Parametric\bin\parametric.exe
name: PTC Creo
startup_args: []
startup_timeout: 60
stop_timeout: 15
pdms:
check_process_name:
- des.exe
- PDMSConsole.exe
executable_path: "C:\\AVEVA\\Plant\\PDMS12.1.SP4\\pdms.bat"
- des.exe
- PDMSConsole.exe
executable_path: C:\AVEVA\Plant\PDMS12.1.SP4\pdms.bat
name: AVEVA PDMS 12.1 SP4
startup_args:
- Design
- noconsole
- Design
- noconsole
startup_timeout: 120
stop_timeout: 20
revit:
check_process_name: Revit.exe
executable_path: "C:\\Program Files\\Autodesk\\Revit 2017\\Revit.exe"
executable_path: C:\Program Files\Autodesk\Revit 2017\Revit.exe
name: Autodesk Revit 2017
startup_args:
- /language
- CHS
- /language
- CHS
startup_timeout: 90
routing:
extension_to_software:
.prt: creo
.asm: creo
.drw: creo
.rvm: pdms
.dri: pdms
.rvt: revit
.rfa: revit
.rte: revit
plugins:
creo:
base_url: "http://localhost:12345"
submit_path: "/api/plugin/tasks"
request_timeout_sec: 10
callback_timeout_sec: 60
max_retries: 1
retry_backoff_sec: [1, 3]
callback_token: "creo-callback-token"
tasks:
open_model:
path: "/api/model/open"
body_mode: "file_path"
shrinkwrap_shell:
path: "/api/creo/shrinkwrap/shell"
body_mode: "task_params_only"
shell_analysis:
path: "/api/analysis/shell-analysis"
body_mode: "task_params_only"
close_model:
path: "/api/model/close"
body_mode: "creo_close_model"
completion_mode: "sync"
pdms:
base_url: "http://localhost:9001"
submit_path: "/api/plugin/tasks"
request_timeout_sec: 10
callback_timeout_sec: 60
max_retries: 1
retry_backoff_sec: [1, 3]
callback_token: "pdms-callback-token"
tasks:
open_project:
path: "/api/project/open"
body_mode: "project_open"
open_mdb:
path: "/api/mdb/open"
body_mode: "project_open"
shrinkwrap_model:
path: "/api/model/shrinkwrap"
body_mode: "task_params_only"
simplify_model:
path: "/api/model/simplify"
body_mode: "task_params_only"
close_project:
path: "/api/project/close"
body_mode: "task_params_only"
revit:
base_url: "http://localhost:9000"
submit_path: "/api/plugin/tasks"
request_timeout_sec: 10
callback_timeout_sec: 60
max_retries: 1
retry_backoff_sec: [1, 3]
callback_token: "revit-callback-token"
tasks:
open_model:
path: "/api/open"
body_mode: "file_path"
shell_analyze:
path: "/api/shell/analyze"
body_mode: "task_params_only"
shell_execute:
path: "/api/shell/execute"
body_mode: "task_params_only"
close_model:
path: "/api/close"
body_mode: "empty"
completion_mode: "sync"