Skip to content

Commit

Permalink
core: services: ardupilotmanager: reduce verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed May 23, 2024
1 parent ad243b7 commit 05d1d9c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/services/ardupilot_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path
from typing import Any, Dict, List, Optional, Set

from commonwealth.mavlink_comm.exceptions import FetchUpdatedMessageFail
from commonwealth.mavlink_comm.typedefs import FirmwareInfo, MavlinkVehicleType
from commonwealth.utils.apis import (
GenericErrorHandlingRoute,
Expand All @@ -17,7 +18,7 @@
from commonwealth.utils.general import is_running_as_root
from commonwealth.utils.logs import InterceptHandler, init_logger
from fastapi import Body, FastAPI, File, HTTPException, UploadFile, status
from fastapi.responses import HTMLResponse
from fastapi.responses import HTMLResponse, PlainTextResponse
from fastapi_versioning import VersionedFastAPI, version
from loguru import logger
from uvicorn import Config, Server
Expand Down Expand Up @@ -122,15 +123,21 @@ def get_serials() -> Any:
async def get_firmware_info() -> Any:
if not autopilot.current_board:
raise RuntimeError("Cannot fetch firmware info as there's no board running.")
return await autopilot.vehicle_manager.get_firmware_info()
try:
return await autopilot.vehicle_manager.get_firmware_info()
except ValueError:
return PlainTextResponse("Failed to get autopilot version", status_code=500)


@app.get("/vehicle_type", response_model=MavlinkVehicleType, summary="Get mavlink vehicle type.")
@version(1, 0)
async def get_vehicle_type() -> Any:
if not autopilot.current_board:
raise RuntimeError("Cannot fetch vehicle type info as there's no board running.")
return await autopilot.vehicle_manager.get_vehicle_type()
try:
return await autopilot.vehicle_manager.get_vehicle_type()
except FetchUpdatedMessageFail as error:
return PlainTextResponse(f"timed out fetching message: {error}", status_code=500)


@app.post("/sitl_frame", summary="Set SITL Frame type.")
Expand Down

0 comments on commit 05d1d9c

Please sign in to comment.