Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed Nov 17, 2023
1 parent 8d598f2 commit 857eb6b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
14 changes: 11 additions & 3 deletions src/fprime_gds/common/communication/updown.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class Downlinker:
"""

def __init__(
self, adapter: BaseAdapter, ground: GroundHandler, deframer: FramerDeframer, discarded=None
self,
adapter: BaseAdapter,
ground: GroundHandler,
deframer: FramerDeframer,
discarded=None,
):
"""Initialize the downlinker
Expand All @@ -61,10 +65,14 @@ def __init__(

def start(self):
"""Starts the downlink pipeline"""
self.th_ground = threading.Thread(target=self.sending, name="DownlinkTTSGroundThread")
self.th_ground = threading.Thread(
target=self.sending, name="DownlinkTTSGroundThread"
)
self.th_ground.daemon = True
self.th_ground.start()
self.th_data = threading.Thread(target=self.deframing, name="DownLinkDeframingThread")
self.th_data = threading.Thread(
target=self.deframing, name="DownLinkDeframingThread"
)
self.th_data.daemon = True
self.th_data.start()

Expand Down
6 changes: 5 additions & 1 deletion src/fprime_gds/common/logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def configure_py_log(directory=None, filename=sys.argv[0], mirror_to_stdout=Fals
global INITIALIZED
if INITIALIZED:
return
handlers = [logging.StreamHandler(sys.stdout)] if directory is None or mirror_to_stdout else []
handlers = (
[logging.StreamHandler(sys.stdout)]
if directory is None or mirror_to_stdout
else []
)
if directory is not None:
log_file = os.path.join(directory, os.path.basename(filename))
log_file = log_file if log_file.endswith(".log") else f"{log_file}.log"
Expand Down
21 changes: 11 additions & 10 deletions src/fprime_gds/executables/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,16 @@ def handle_arguments(self, args, **kwargs):
if likely_deployment.exists():
args.deployment = likely_deployment
return args
child_directories = [child for child in detected_toolchain.iterdir() if child.is_dir()]
child_directories = [
child for child in detected_toolchain.iterdir() if child.is_dir()
]
if not child_directories:
msg = f"No deployments found in {detected_toolchain}. Specify deployment with: --deployment"
raise Exception(msg)
# Works for the old structure where the bin, lib, and dict directories live immediately under the platform
elif len(child_directories) == 3 and set([path.name for path in child_directories]) == {"bin", "lib", "dict"}:
elif len(child_directories) == 3 and set(
[path.name for path in child_directories]
) == {"bin", "lib", "dict"}:
args.deployment = detected_toolchain
return args
elif len(child_directories) > 1:
Expand Down Expand Up @@ -310,8 +314,7 @@ def get_arguments(self) -> Dict[Tuple[str, ...], Dict[str, Any]]:
"action": "store",
"type": str,
"help": "Adapter for communicating to flight deployment. [default: %(default)s]",
"choices": ["none"]
+ list(adapter_definition_dictionaries),
"choices": ["none"] + list(adapter_definition_dictionaries),
"default": "ip",
},
("--comm-checksum-type",): {
Expand All @@ -333,8 +336,8 @@ def get_arguments(self) -> Dict[Tuple[str, ...], Dict[str, Any]]:
"help": "Log unframed data to supplied file relative to log directory. Use '-' for standard out.",
"default": None,
"const": "unframed.log",
"required": False
}
"required": False,
},
}
return {**adapter_arguments, **com_arguments}

Expand Down Expand Up @@ -708,9 +711,7 @@ def handle_arguments(self, args, **kwargs):
args.app = Path(args.app) if args.app else Path(find_app(args.deployment))
if not args.app.is_file():
msg = f"F prime binary '{args.app}' does not exist or is not a file"
raise ValueError(
msg
)
raise ValueError(msg)
return args


Expand All @@ -737,7 +738,7 @@ def get_arguments(self) -> Dict[Tuple[str, ...], Dict[str, Any]]:
"action": "store",
"required": False,
"type": int,
"nargs":'+',
"nargs": "+",
"help": f"only show {self.command_name} matching the given type ID(s) 'ID'; can provide multiple IDs to show all given types",
"metavar": "ID",
},
Expand Down
19 changes: 15 additions & 4 deletions src/fprime_gds/executables/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,30 @@ def main():
# Set the framing class used and pass it to the uplink and downlink component constructions giving each a separate
# instantiation
framer_class = FpFramerDeframer
LOGGER.info("Starting uplinker/downlinker connecting to FSW using %s with %s", adapter, framer_class.__name__)
LOGGER.info(
"Starting uplinker/downlinker connecting to FSW using %s with %s",
adapter,
framer_class.__name__,
)
discarded_file_handle = None
try:
if args.output_unframed_data == "-":
discarded_file_handle = sys.stdout.buffer
elif args.output_unframed_data is not None:
discarded_file_handle_path = (Path(args.logs) / Path(args.output_unframed_data)).resolve()
discarded_file_handle_path = (
Path(args.logs) / Path(args.output_unframed_data)
).resolve()
try:
discarded_file_handle = open(discarded_file_handle_path, "wb")
LOGGER.info("Logging unframed data to %s", discarded_file_handle_path)
except OSError:
LOGGER.warning("Failed to open %s. Unframed data will be discarded.", discarded_file_handle_path)
downlinker = Downlinker(adapter, ground, framer_class(), discarded=discarded_file_handle)
LOGGER.warning(
"Failed to open %s. Unframed data will be discarded.",
discarded_file_handle_path,
)
downlinker = Downlinker(
adapter, ground, framer_class(), discarded=discarded_file_handle
)
uplinker = Uplinker(adapter, ground, framer_class(), downlinker)

# Open resources for the handlers on either side, this prepares the resources needed for reading/writing data
Expand Down

0 comments on commit 857eb6b

Please sign in to comment.