Skip to content

Commit

Permalink
Merge pull request #27 from CarletonURocketry/modify_linting_config
Browse files Browse the repository at this point in the history
Move configurations to pyproject.toml where applicable and update configurations.
  • Loading branch information
linguini1 authored Jun 16, 2023
2 parents f8b752e + efac40a commit 9405e1d
Show file tree
Hide file tree
Showing 32 changed files with 379 additions and 396 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ dmypy.json
/missions/

# Misc
/.idea/
.idea/
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/ground-station.iml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

26 changes: 0 additions & 26 deletions .idea/jsonSchemas.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/vcs.xml

This file was deleted.

26 changes: 15 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# Thomas Selwyn (Devil)
# Matteo Golin (linguini1)

from multiprocessing import Process, Queue
import multiprocessing as mp
from multiprocessing import Process
from queue import Queue
from re import sub
import logging
from typing import TypeAlias, Any
from modules.misc.config import load_config

from modules.misc.messages import print_cu_rocket
Expand All @@ -16,6 +19,7 @@
from modules.websocket.websocket import WebSocketHandler
from modules.misc.cli import parser

JSON: TypeAlias = dict[str, Any]
VERSION: str = "0.5.0-DEV"
STR_TO_LOGGING_MODE: dict[str, int] = {
"debug": logging.DEBUG,
Expand All @@ -35,7 +39,7 @@ class ShutdownException(Exception):

# Set up logging

log_handlers: list = [logging.StreamHandler()] # Always print to stdout
log_handlers: list[logging.Handler] = [logging.StreamHandler()] # Always print to stdout
if args.get("o") is not None:
log_handlers.append(logging.FileHandler(args.get("o", "logfile.log")))

Expand All @@ -48,15 +52,15 @@ class ShutdownException(Exception):

def main():
# Set up queues
serial_status = Queue()
ws_commands = Queue()
serial_ws_commands = Queue()
telemetry_ws_commands = Queue()
serial_status: Queue[str] = mp.Queue() # type: ignore
ws_commands: Queue[str] = mp.Queue() # type: ignore
serial_ws_commands: Queue[list[str]] = mp.Queue() # type: ignore
telemetry_ws_commands: Queue[list[str]] = mp.Queue() # type: ignore

radio_signal_report = Queue()
rn2483_radio_input = Queue()
rn2483_radio_payloads = Queue()
telemetry_json_output = Queue()
radio_signal_report: Queue[str] = mp.Queue() # type: ignore
rn2483_radio_input: Queue[str] = mp.Queue() # type: ignore
rn2483_radio_payloads: Queue[str] = mp.Queue() # type: ignore
telemetry_json_output: Queue[JSON] = mp.Queue() # type: ignore

# Print display screen
print_cu_rocket("No Name (Gas Propelled Launching Device)", VERSION)
Expand Down Expand Up @@ -123,7 +127,7 @@ def main():
exit(0)


def parse_ws_command(ws_cmd: str, serial_commands: Queue, telemetry_commands: Queue) -> None:
def parse_ws_command(ws_cmd: str, serial_commands: Queue[list[str]], telemetry_commands: Queue[list[str]]) -> None:
"""Parses a websocket command and places it on the correct process queue (telemetry or serial)."""

# Remove special characters
Expand Down
10 changes: 5 additions & 5 deletions modules/misc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@

# Custom types
def file_path(path: str):
"""Verifies that the argument is a valid filepath."""
"""Verifies that the argument is a valid file path."""

if os.path.isfile(path) or os.access(os.path.dirname(path), os.W_OK):
return path
else:
raise FileNotFoundError(f"{path} is not a valid filepath.")
raise FileNotFoundError(f"{path} is not a valid file path.")


# Arguments
parser = argparse.ArgumentParser(description=DESC)

parser.add_argument(
_ = parser.add_argument(
"-l",
help="Selects the logging level for messages in the console.",
choices=["debug", "info", "warning", "error", "critical"],
default="info"
default="info",
)

parser.add_argument(
_ = parser.add_argument(
"-o",
help="Output file for logging messages. Logs to console by default.",
type=file_path,
Expand Down
5 changes: 2 additions & 3 deletions modules/misc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class RadioParameters:
def __post_init__(self):
if self.frequency not in range(*LF_RANGE) and self.frequency not in range(*HF_RANGE):
raise ValueError(
f"Frequency '{self.frequency}' not in low frequency range {LF_RANGE} "
f"or high frequency range {HF_RANGE}"
f"Frequency '{self.frequency}' not in low frequency range {LF_RANGE} or high frequency range {HF_RANGE}"
)

if self.power not in range(*POWER_RANGE):
Expand Down Expand Up @@ -127,7 +126,7 @@ class Config:
approved_callsigns: dict[str, str] = field(default_factory=dict)

def __post_init__(self):
if self.approved_callsigns is None or len(self.approved_callsigns) == 0:
if len(self.approved_callsigns) == 0:
raise ValueError("You must provide at least one approved callsign.")

@classmethod
Expand Down
7 changes: 4 additions & 3 deletions modules/misc/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
# Thomas Selwyn (Devil)
# Matteo Golin (linguini1)


def celsius_to_fahrenheit(celsius: float) -> float:
""" Returns the passed Celsius value in Fahrenheit as a float. """
"""Returns the passed Celsius value in Fahrenheit as a float."""

return round((celsius * 1.8) + 32, 1)


def metres_to_feet(metres: float) -> float:
""" Returns the passed metres value in feet as a float. """
"""Returns the passed metres value in feet as a float."""

return round(metres * 3.28, 1)


def pascals_to_psi(pascals: int) -> float:
""" Returns the passed pascals value in psi as a float. """
"""Returns the passed pascals value in psi as a float."""

return round(pascals / 6895, 2)
Loading

0 comments on commit 9405e1d

Please sign in to comment.