Skip to content

Commit 98dbd3f

Browse files
committed
test(flightcontroller info): Add more tests, improve the code
1 parent d66dd87 commit 98dbd3f

2 files changed

Lines changed: 486 additions & 14 deletions

File tree

ardupilot_methodic_configurator/frontend_tkinter_flightcontroller_info.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tkinter as tk
1212

1313
# from logging import debug as logging_debug
14+
from logging import error as logging_error
1415
from logging import info as logging_info
1516
from tkinter import ttk
1617

@@ -71,12 +72,21 @@ def __init__(self, flight_controller: FlightController) -> None:
7172
self.root.mainloop()
7273

7374
def download_flight_controller_parameters(self) -> None:
75+
"""Download parameters from the flight controller with progress tracking and error handling."""
7476
param_download_progress_window = ProgressWindow(
7577
self.root, _("Downloading FC parameters"), _("Downloaded {} of {} parameters")
7678
)
77-
self.flight_controller.fc_parameters, self.param_default_values = self.flight_controller.download_params(
78-
param_download_progress_window.update_progress_bar
79-
)
79+
try:
80+
self.flight_controller.fc_parameters, self.param_default_values = self.flight_controller.download_params(
81+
param_download_progress_window.update_progress_bar
82+
)
83+
except Exception as e:
84+
logging_error(_("Error downloading flight controller parameters: %s"), str(e))
85+
# Make sure to destroy the progress window even on error
86+
param_download_progress_window.destroy()
87+
# Re-raise the exception after cleanup
88+
raise
89+
# Normal cleanup path when no exceptions occur
8090
param_download_progress_window.destroy() # for the case that '--device test' and there is no real FC connected
8191
self.root.destroy()
8292

0 commit comments

Comments
 (0)