Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FirmwareFlasher] Change Menu Calls to Returns #193

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions scripts/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,14 +1188,14 @@ def query_devices(self):
Utils.error_msg("No CAN devices found.")
else:
Utils.error_msg("Unexpected output format.")
self.menu()
return

except subprocess.CalledProcessError as e:
Utils.error_msg(f"Error querying CAN devices: {e}")
self.menu()
return
except Exception as e:
Utils.error_msg(f"Unexpected error: {e}")
self.menu()
return
finally:
# Define menu items, starting with UUID options
menu_items: Dict[int, Union[Menu.Item, Menu.Separator]] = {}
Expand Down Expand Up @@ -1389,15 +1389,14 @@ def query_devices(self):

if not self.katapult.install():
Utils.error_msg("Error with Katapult")
self.menu()
return
detected_devices: List[str] = []
try:
# List all devices in /dev/serial/by-id/
base_path = "/dev/serial/by-id/"
if not os.path.exists(base_path):
Utils.error_msg(f"Path '{base_path}' does not exist.")
self.menu()
return

for device in os.listdir(base_path):
if "Cartographer" in device or "katapult" in device:
Expand All @@ -1407,7 +1406,6 @@ def query_devices(self):
Utils.error_msg(
"No devices containing 'Cartographer' or 'katapult' found."
)
self.menu()
return

# Display the detected devices
Expand All @@ -1419,7 +1417,7 @@ def query_devices(self):

except Exception as e:
Utils.error_msg(f"Unexpected error while querying devices: {e}")
self.menu()
return

# Define menu items, starting with detected devices
menu_items: Dict[int, Union[Menu.Item, Menu.Separator]] = {}
Expand Down
Loading