Skip to content

Commit

Permalink
core: autopilot-manager: Move Ardu to Auto naming
Browse files Browse the repository at this point in the history
* Move class name only from ArduPilotManager to AutoPilotManager
* Move Ardu to Auto in README
* Move diverse general (Not specific like settings) uses of ArduPilot to
  AutoPilot
  • Loading branch information
JoaoMario109 committed Oct 3, 2024
1 parent db7f891 commit 77856fb
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion core/services/ardupilot_manager/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# ArduPilot service manager
# AutoPilot service manager
6 changes: 3 additions & 3 deletions core/services/ardupilot_manager/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from api.v2.routers import index_router_v2

application = FastAPI(
title="ArduPilot Manager API",
description="ArduPilot Manager is responsible for managing ArduPilot devices connected to BlueOS.",
title="AutoPilot Manager API",
description="AutoPilot Manager is responsible for managing AutoPilot devices connected to BlueOS.",
default_response_class=PrettyJSONResponse,
debug=True, # TODO - Add debug after based on args
)
Expand All @@ -33,7 +33,7 @@ async def root() -> HTMLResponse:
html_content = """
<html>
<head>
<title>ArduPilot Manager</title>
<title>AutoPilot Manager</title>
</head>
</html>
"""
Expand Down
4 changes: 2 additions & 2 deletions core/services/ardupilot_manager/api/v1/routers/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter, Body, status
from fastapi_versioning import versioned_api_route

from ArduPilotManager import ArduPilotManager
from autopilot_manager import AutoPilotManager
from mavlink_proxy.Endpoint import Endpoint

endpoints_router_v1 = APIRouter(
Expand All @@ -13,7 +13,7 @@
responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
)

autopilot = ArduPilotManager()
autopilot = AutoPilotManager()


@endpoints_router_v1.get("/", response_model=List[Dict[str, Any]])
Expand Down
4 changes: 2 additions & 2 deletions core/services/ardupilot_manager/api/v1/routers/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from fastapi_versioning import versioned_api_route
from loguru import logger

from ArduPilotManager import ArduPilotManager
from autopilot_manager import AutoPilotManager
from exceptions import InvalidFirmwareFile
from typedefs import Firmware, FlightController, Parameters, Serial, SITLFrame, Vehicle

Expand All @@ -26,7 +26,7 @@
responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
)

autopilot = ArduPilotManager()
autopilot = AutoPilotManager()


# By default, all REST resources should have its own router, but as some of them does not implement
Expand Down
2 changes: 1 addition & 1 deletion core/services/ardupilot_manager/api/v2/routers/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async def root_v2() -> HTMLResponse:
html_content = """
<html>
<head>
<title>ArduPilot Manager</title>
<title>AutoPilot Manager</title>
</head>
</html>
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from loguru import logger

from exceptions import (
ArdupilotProcessKillFail,
AutoPilotProcessKillFail,
NoDefaultFirmwareAvailable,
NoPreferredBoardSet,
)
Expand All @@ -37,7 +37,7 @@
)


class ArduPilotManager(metaclass=Singleton):
class AutoPilotManager(metaclass=Singleton):
# pylint: disable=too-many-instance-attributes
def __init__(self) -> None:
self.settings = Settings()
Expand Down Expand Up @@ -476,7 +476,7 @@ async def terminate_ardupilot_subprocess(self) -> None:
return
logger.debug("Waiting for process to die...")
await asyncio.sleep(0.5)
raise ArdupilotProcessKillFail("Could not terminate Ardupilot subprocess.")
raise AutoPilotProcessKillFail("Could not terminate Ardupilot subprocess.")
logger.warning("Ardupilot subprocess already not running.")

async def prune_ardupilot_processes(self) -> None:
Expand All @@ -497,7 +497,7 @@ async def prune_ardupilot_processes(self) -> None:
try:
subprocess.run(["pkill", "-9", process.pid], check=True)
except Exception as error:
raise ArdupilotProcessKillFail(f"Failed to kill {process.name()}::{process.pid}.") from error
raise AutoPilotProcessKillFail(f"Failed to kill {process.name()}::{process.pid}.") from error

async def kill_ardupilot(self) -> None:
self.should_be_running = False
Expand Down
14 changes: 7 additions & 7 deletions core/services/ardupilot_manager/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Ardupilot-manager exception classes.
AutoPilot-manager exception classes.
"""


Expand All @@ -12,11 +12,11 @@ class NoVersionAvailable(ValueError):


class InvalidManifest(ValueError):
"""Ardupilot manifest file cannot be validated."""
"""AutoPilot manifest file cannot be validated."""


class ManifestUnavailable(RuntimeError):
"""Ardupilot manifest file unavailable."""
"""AutoPilot manifest file unavailable."""


class NoCandidate(ValueError):
Expand Down Expand Up @@ -44,19 +44,19 @@ class InvalidFirmwareFile(ValueError):


class UndefinedPlatform(ValueError):
"""Ardupilot platform is not defined."""
"""AutoPilot platform is not defined."""


class UnsupportedPlatform(ValueError):
"""Ardupilot platform not supported."""
"""AutoPilot platform not supported."""


class FirmwareInstallFail(RuntimeError):
"""Firmware install operation failed."""


class ArdupilotProcessKillFail(RuntimeError):
"""Could not kill Ardupilot process."""
class AutoPilotProcessKillFail(RuntimeError):
"""Could not kill AutoPilot process."""


class NoDefaultFirmwareAvailable(RuntimeError):
Expand Down
8 changes: 4 additions & 4 deletions core/services/ardupilot_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
from loguru import logger
from uvicorn import Config, Server

from ArduPilotManager import ArduPilotManager
from args import CommandLineArgs
from autopilot_manager import AutoPilotManager
from flight_controller_detector.Detector import Detector as BoardDetector
from settings import SERVICE_NAME

logging.basicConfig(handlers=[InterceptHandler()], level=0)
init_logger(SERVICE_NAME)

logger.info("Starting ArduPilot Manager.")
autopilot = ArduPilotManager()
logger.info("Starting AutoPilot Manager.")
autopilot = AutoPilotManager()

from api import application

if not is_running_as_root():
raise RuntimeError("ArduPilot manager needs to run with root privilege.")
raise RuntimeError("AutoPilot manager needs to run with root privilege.")

if __name__ == "__main__":
args = CommandLineArgs.from_args()
Expand Down
2 changes: 1 addition & 1 deletion core/services/ardupilot_manager/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
version="0.0.1",
author="Patrick José Pereira",
author_email="[email protected]",
description="ArduPilot service manager.",
description="AutoPilot service manager.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
Expand Down

0 comments on commit 77856fb

Please sign in to comment.