From fa714249f448257826d39493505661a7980c9342 Mon Sep 17 00:00:00 2001 From: David Conner Date: Tue, 2 Jul 2024 11:56:02 -0400 Subject: [PATCH] minor clean up from flake8/pycodestyle --- .../flexbe_core/core/concurrency_container.py | 6 ++-- .../core/manually_transitionable_state.py | 2 +- .../core/operatable_state_machine.py | 2 +- .../core/preemptable_state_machine.py | 1 + flexbe_mirror/flexbe_mirror/flexbe_mirror.py | 29 +++++++++---------- .../flexbe_onboard/flexbe_onboard.py | 6 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/flexbe_core/flexbe_core/core/concurrency_container.py b/flexbe_core/flexbe_core/core/concurrency_container.py index 1f3aeec..cc3aa61 100644 --- a/flexbe_core/flexbe_core/core/concurrency_container.py +++ b/flexbe_core/flexbe_core/core/concurrency_container.py @@ -106,7 +106,7 @@ def _execute_current_state(self): if command_msg.target == self.name: cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC) # Using here, so clear from buffer - assert cmd_msg2 is command_msg, "Unexpected change in CMD_TRANSITION_TOPIC buffer" + assert cmd_msg2 is command_msg, 'Unexpected change in CMD_TRANSITION_TOPIC buffer' Logger.localinfo(f"-concurrency container '{self.name}' is handling the transition cmd msg={command_msg}") self._force_transition = True @@ -140,9 +140,9 @@ def _execute_current_state(self): # @TODO - Should we be using path not name here? command_msg = self._manual_transition_requested cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC) # Using here, so clear from buffer - assert cmd_msg2 is command_msg, "Something is up with handling of buffer for CMD_TRANSITION_TOPIC" + assert cmd_msg2 is command_msg, 'Something is up with handling of buffer for CMD_TRANSITION_TOPIC' Logger.localinfo(f"-concurrency container '{self.name}' state '{state.name}' is handling " - f"the cmd msg={command_msg}") + f"the cmd msg='{command_msg}'") self._manual_transition_requested = None # Reset at this level if 0 <= command_msg.outcome < len(state.outcomes): diff --git a/flexbe_core/flexbe_core/core/manually_transitionable_state.py b/flexbe_core/flexbe_core/core/manually_transitionable_state.py index 822c2bf..4deb24f 100644 --- a/flexbe_core/flexbe_core/core/manually_transitionable_state.py +++ b/flexbe_core/flexbe_core/core/manually_transitionable_state.py @@ -60,7 +60,7 @@ def _manually_transitionable_execute(self, *args, **kwargs): command_msg = self._sub.peek_at_buffer(Topics._CMD_TRANSITION_TOPIC) if command_msg.target == self.name: cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC) - assert cmd_msg2 is command_msg, "Unexpected change in CMD_TRANSITION_TOPIC buffer" + assert cmd_msg2 is command_msg, 'Unexpected change in CMD_TRANSITION_TOPIC buffer' self._pub.publish(Topics._CMD_FEEDBACK_TOPIC, CommandFeedback(command='transition', args=[command_msg.target, self.name])) diff --git a/flexbe_core/flexbe_core/core/operatable_state_machine.py b/flexbe_core/flexbe_core/core/operatable_state_machine.py index 85f8829..a46caf7 100644 --- a/flexbe_core/flexbe_core/core/operatable_state_machine.py +++ b/flexbe_core/flexbe_core/core/operatable_state_machine.py @@ -112,7 +112,7 @@ def define_structure(self): """Calculate all state ids and prepare the ContainerStructure message.""" self._state_map = StateMap() self._structure = self._build_structure_msg() - print(f"\x1b[94mBuilt {self._state_map}\x1b[0m", flush=True) + print(f'\x1b[94mBuilt {self._state_map}\x1b[0m', flush=True) def _build_structure_msg(self): """Create a message to describe the structure of this state machine.""" diff --git a/flexbe_core/flexbe_core/core/preemptable_state_machine.py b/flexbe_core/flexbe_core/core/preemptable_state_machine.py index c0d7340..dacabe3 100644 --- a/flexbe_core/flexbe_core/core/preemptable_state_machine.py +++ b/flexbe_core/flexbe_core/core/preemptable_state_machine.py @@ -36,6 +36,7 @@ from flexbe_core.core.preemptable_state import PreemptableState from flexbe_core.core.topics import Topics from flexbe_core.logger import Logger + from flexbe_msgs.msg import CommandFeedback import rclpy diff --git a/flexbe_mirror/flexbe_mirror/flexbe_mirror.py b/flexbe_mirror/flexbe_mirror/flexbe_mirror.py index b25db38..8f4c26c 100644 --- a/flexbe_mirror/flexbe_mirror/flexbe_mirror.py +++ b/flexbe_mirror/flexbe_mirror/flexbe_mirror.py @@ -29,6 +29,9 @@ """Class to handle the FlexBE mirror of onboard statemachine.""" +import threading +import time +import traceback from collections import deque try: @@ -39,10 +42,6 @@ def set_thread_name(name): # print('Python thread names are not visible in ps/top unless you install prctl') pass -import threading -import time -import traceback - from flexbe_core import Logger, MIN_UI_VERSION from flexbe_core.core import LockableStateMachine, OperatableStateMachine from flexbe_core.core import PreemptableState, PreemptableStateMachine, StateMap @@ -62,16 +61,16 @@ def set_thread_name(name): from .mirror_state_machine import MirrorStateMachine bestatus_map = { - BEStatus.STARTED: "STARTED", - BEStatus.FINISHED: "FINISHED", - BEStatus.FAILED: "FAILED", - BEStatus.LOCKED: "LOCKED", - BEStatus.WAITING: "WAITING", - BEStatus.SWITCHING: "SWITCHING", - BEStatus.WARNING: "WARNING", - BEStatus.ERROR: "ERROR", - BEStatus.READY: "READY", - BEStatus.RUNNING: "RUNNING", + BEStatus.STARTED: 'STARTED', + BEStatus.FINISHED: 'FINISHED', + BEStatus.FAILED: 'FAILED', + BEStatus.LOCKED: 'LOCKED', + BEStatus.WAITING: 'WAITING', + BEStatus.SWITCHING: 'SWITCHING', + BEStatus.WARNING: 'WARNING', + BEStatus.ERROR: 'ERROR', + BEStatus.READY: 'READY', + BEStatus.RUNNING: 'RUNNING', } @@ -801,7 +800,7 @@ def _mirror_state_machine(self, msg): assert path_seg in state.path, (f'Mismatched state id={state.state_id} for {state.path} vs. ' f'({con_msg.state_id}) {con_msg.path}') else: - raise KeyError(f"State id {con_msg.state_id} not found in {self._state_map}!") + raise KeyError(f'State id {con_msg.state_id} not found in {self._state_map}!') end = time.time() Logger.localinfo(f"Validated constructed mirror for behavior id ='{self._sm.id}' in {end - start} seconds !") return # success here diff --git a/flexbe_onboard/flexbe_onboard/flexbe_onboard.py b/flexbe_onboard/flexbe_onboard/flexbe_onboard.py index de3b768..fac98c1 100644 --- a/flexbe_onboard/flexbe_onboard/flexbe_onboard.py +++ b/flexbe_onboard/flexbe_onboard/flexbe_onboard.py @@ -155,8 +155,8 @@ def _parse_version(v): def _behavior_callback(self, beh_sel_msg): if self._starting: # Prevent multiple request messages from triggering too soon - Logger.logwarn(f"Received behavior start request for {beh_sel_msg.behavior_key} " - f"({beh_sel_msg.behavior_id}) while prior request was starting.\n Ignore second request!") + Logger.logwarn(f'Received behavior start request for {beh_sel_msg.behavior_key} ' + f'({beh_sel_msg.behavior_id}) while prior request was starting.\n Ignore second request!') return self._starting = True # Prevent two start requests from ocurring back to back self._trigger_ready = False # We have received the behavior selection request @@ -357,7 +357,7 @@ def _behavior_execution(self, beh_sel_msg): self._status_pub.publish(BEStatus(stamp=self.get_clock().now().to_msg(), code=BEStatus.READY)) Logger.localinfo('\033[92m--- Behavior Engine finished - ready for more! ---\033[0m') - Logger.localinfo(f"Behavior execution finished for id={self.be.beh_id}, exit thread!") + Logger.localinfo(f'Behavior execution finished for id={self.be.beh_id}, exit thread!') self._running = False self._switching = False self.be = None