Tools: avoid errors for catching bare exception

This commit is contained in:
Peter Barker
2026-03-23 08:14:01 +11:00
committed by Peter Barker
parent 75af5ac540
commit bc1aa19b28
22 changed files with 84 additions and 84 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ def configure(cfg):
try:
hwdef_obj = generate_hwdef_h(env)
except Exception:
except Exception: # noqa: BLE001
traceback.print_exc()
cfg.fatal("Failed to process hwdef.dat")
hal_common.process_hwdef_results(cfg, hwdef_obj)
+1 -1
View File
@@ -47,7 +47,7 @@ def configure(cfg):
try:
hwdef_obj = generate_hwdef_h(env)
except Exception:
except Exception: # noqa: BLE001
traceback.print_exc()
cfg.fatal("Failed to process hwdef.dat")
hal_common.process_hwdef_results(cfg, hwdef_obj)
+12 -12
View File
@@ -3265,7 +3265,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
if ((flow_scalar_y > 30) or (flow_scalar_y < -30)):
raise NotAchievedException("FlowCal failed to set FLOW_FYSCALER correctly")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -4929,7 +4929,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
self.set_rc(2, 1500)
self.do_RTL()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
self.disarm_vehicle(force=True)
ex = e
@@ -5161,7 +5161,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
if not self.current_onboard_log_contains_message("PL"):
raise NotAchievedException("Did not see expected PL message")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.reboot_sitl()
@@ -9103,7 +9103,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
self.set_rc(2, 1500)
self.do_RTL()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.context_pop()
@@ -10366,7 +10366,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
)
try:
self.arm_vehicle()
except Exception:
except Exception: # noqa: BLE001
pass
self.delay_sim_time(1) # servo function maps only periodically updated
# self.send_debug_trap()
@@ -10394,7 +10394,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
self.delay_sim_time(0.1)
try:
self.wait_text("LandingGear: RETRACT", check_context=True, timeout=0.1)
except Exception:
except Exception: # noqa: BLE001
continue
self.progress("Retracted")
break
@@ -10415,13 +10415,13 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
)
try:
self.wait_text("LandingGear: DEPLOY", check_context=True, timeout=0.1)
except Exception:
except Exception: # noqa: BLE001
continue
self.progress("Deployed")
break
self.disarm_vehicle()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.context_pop()
@@ -10596,7 +10596,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
(expected_dist, rf.min_distance))
self.context_pop()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -11733,7 +11733,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
self.assert_message_rate_hz("ATTITUDE", 20)
self.assert_message_rate_hz("SCALED_PRESSURE", 5)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -12548,7 +12548,7 @@ class AutoTestCopter(vehicle_test_suite.TestSuite):
self.wait_extended_sys_state(vtol_state=mavutil.mavlink.MAV_VTOL_STATE_MC,
landed_state=mavutil.mavlink.MAV_LANDED_STATE_IN_AIR, timeout=60)
self.land_and_disarm()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.set_message_rate_hz(mavutil.mavlink.MAVLINK_MSG_ID_EXTENDED_SYS_STATE, -1)
@@ -15496,7 +15496,7 @@ RTL_ALT_M 111
self.assert_receive_message('HEARTBEAT', mav=mav3, verbose=2)
self.drain_mav()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
finally:
+1 -1
View File
@@ -4594,7 +4594,7 @@ class AutoTestPlane(vehicle_test_suite.TestSuite):
raise NotAchievedException(
"New home not where it should be (dist=%f) (want=%s) (got=%s)" %
(delta, str(new_home), str(post_reboot_home)))
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
+5 -5
View File
@@ -99,7 +99,7 @@ def build_examples(**kwargs):
print("Running build.examples for %s" % target)
try:
util.build_examples(target, **kwargs)
except Exception as e:
except Exception as e: # noqa: BLE001
print("Failed build_examples on board=%s" % target)
print(str(e))
return False
@@ -113,7 +113,7 @@ def build_unit_tests(**kwargs):
print("Running build.unit_tests for %s" % target)
try:
util.build_tests(target, **kwargs)
except Exception as e:
except Exception as e: # noqa: BLE001
print("Failed build.unit_tests on board=%s" % target)
print(str(e))
return False
@@ -249,7 +249,7 @@ def alarm_handler(signum, frame):
convert_gpx()
write_fullresults()
os.killpg(0, signal.SIGKILL)
except Exception:
except Exception: # noqa: BLE001
pass
sys.exit(1)
@@ -297,7 +297,7 @@ def binary_path(step, debug=False):
"""Get vehicle binary path."""
try:
vehicle = step.split(".")[1]
except Exception:
except IndexError:
return None
if vehicle not in __bin_names:
@@ -751,7 +751,7 @@ def run_tests(steps):
failed_testinstances[step].append(testinstance)
results.add(step, '<span class="failed-text">FAILED</span>',
time.time() - t1)
except Exception as msg:
except Exception as msg: # noqa: BLE001
passed = False
failed.append(step)
print(">>>> FAILED STEP: %s at %s (%s)" %
+1 -1
View File
@@ -85,7 +85,7 @@ class AutoTestBalanceBot(AutoTestRover):
if delta > 5:
raise NotAchievedException("wheel distance incorrect")
self.disarm_vehicle()
except Exception as e:
except Exception as e: # noqa: BLE001
self.progress("Caught exception: %s" %
self.get_exception_stacktrace(e))
self.disarm_vehicle()
+1 -1
View File
@@ -375,7 +375,7 @@ if __name__ == '__main__':
try:
bisecter.run()
except Exception as e:
except Exception as e: # noqa: BLE001
print("Caught exception in bisect-helper: %s" % str(e))
print(get_exception_stacktrace(e))
sys.exit(129) # should abort the bisect process
+1 -1
View File
@@ -131,7 +131,7 @@ def run_examples(debug=False, valgrind=False, gdb=False):
continue
try:
run_example(afile, filepath, valgrind=valgrind, gdb=gdb)
except Exception as e:
except Exception as e: # noqa: BLE001
print("Example failed with exception")
print_exception_stacktrace(e)
failures.append(afile)
+3 -3
View File
@@ -315,11 +315,11 @@ def pexpect_close(p):
time.sleep(0.05)
try:
p.close()
except Exception:
except Exception: # noqa: BLE001
pass
try:
p.close(force=True)
except Exception:
except Exception: # noqa: BLE001
pass
if p in close_list:
close_list.remove(p)
@@ -335,7 +335,7 @@ def pexpect_drain(p):
"""Drain any pending input."""
try:
p.read_nonblocking(1000, timeout=0)
except Exception:
except Exception: # noqa: BLE001
pass
+4 -4
View File
@@ -727,7 +727,7 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
mavproxy.send('switch %u\n' % num)
self.wait_mode(expected)
self.stop_mavproxy(mavproxy)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -1315,13 +1315,13 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
self.mav.mav.srcSystem = 1
self.arm_vehicle(timeout=5)
self.disarm_vehicle()
except Exception as e:
except Exception as e: # noqa: BLE001
comp_arm_exception = e
self.mav.mav.srcSystem = old_srcSystem
if comp_arm_exception is not None:
raise comp_arm_exception
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.mav.mav.srcSystem = old_srcSystem
@@ -4968,7 +4968,7 @@ Brakes have negligible effect (with=%0.2fm without=%0.2fm delta=%0.2fm)
self.wait_location(target, timeout=300)
self.do_RTL()
self.disarm_vehicle()
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.context_pop()
+5 -5
View File
@@ -173,7 +173,7 @@ def cygwin_pidof(proc_name):
if cmd == proc_name:
try:
pid = int(line_split[0].strip())
except Exception:
except ValueError:
pid = int(line_split[1].strip())
if pid not in pids:
pids.append(pid)
@@ -315,7 +315,7 @@ def kill_tasks():
kill_tasks_psutil(victim_names)
except ImportError:
kill_tasks_pkill(victim_names)
except Exception as e:
except Exception as e: # noqa: BLE001
progress("kill_tasks failed: {}".format(str(e)))
@@ -516,7 +516,7 @@ def find_geocoder_location(locname):
# Step 1: Attempt the lookup
try:
j = geocoder.osm(locname)
except Exception as e:
except Exception as e: # noqa: BLE001
# Handle network/blocked errors (like 403)
err_msg = str(e)
if '403' in err_msg:
@@ -604,7 +604,7 @@ def run_cmd_blocking(what, cmd, quiet=False, check=False, **kw):
try:
p = subprocess.Popen(cmd, **kw)
ret = os.waitpid(p.pid, 0)
except Exception as e:
except Exception as e: # noqa: BLE001
print("[%s] An exception has occurred with command: '%s'" % (what, (' ').join(cmd)))
print(e)
sys.exit(1)
@@ -852,7 +852,7 @@ def start_vehicle(binary, opts, stuff, spawns=None):
# Parse start_time into a double precision number specifying seconds since 1900.
try:
start_time_UTC = time.mktime(datetime.datetime.strptime(cmd_opts.start_time, '%Y-%m-%d-%H:%M').timetuple())
except Exception:
except ValueError:
print("Incorrect start time format - require YYYY-MM-DD-HH:MM (given %s)" % cmd_opts.start_time)
sys.exit(1)
+1 -1
View File
@@ -195,7 +195,7 @@ class TestParamUpgradeForVehicle():
path = pathlib.Path(self.tmpdir, f"process-failure-{int(time.time())}")
path.write_text(output)
self.progress("Wrote process failure file (%s)" % path)
except Exception:
except Exception: # noqa: BLE001
self.progress("Writing process failure file failed")
raise subprocess.CalledProcessError(
returncode, cmd_list)
+24 -24
View File
@@ -294,7 +294,7 @@ class Telem(object):
if self.port is not None:
try:
self.port.close() # might be reopening
except Exception:
except Exception: # noqa: BLE001
pass
self.port = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.port.connect(self.destination_address)
@@ -2490,7 +2490,7 @@ class TestSuite(abc.ABC):
pass
except socket.error:
pass
except Exception as e:
except Exception as e: # noqa: BLE001
self.progress("Got unexpected exception (%s)" % str(type(e)))
pass
@@ -3201,7 +3201,7 @@ class TestSuite(abc.ABC):
self.stop_SITL()
try:
del self.valgrind_restart_customisations
except Exception:
except AttributeError:
pass
self.start_SITL(wipe=True)
self.set_streamrate(self.sitl_streamrate())
@@ -3763,7 +3763,7 @@ class TestSuite(abc.ABC):
self.run_cmd_enable_high_latency(False)
self.assert_message_rate_hz("HIGH_LATENCY2", 5, mav=self.mav)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -8551,7 +8551,7 @@ class TestSuite(abc.ABC):
self.progress("Prearm bit never went true. Attempting arm to elicit reason from autopilot")
try:
self.arm_vehicle()
except Exception:
except Exception: # noqa: BLE001
pass
raise AutoTestTimeoutException("Prearm bit never went true")
if self.sensor_has_state(mavutil.mavlink.MAV_SYS_STATUS_PREARM_CHECK, True, True, True):
@@ -9147,7 +9147,7 @@ Also, ignores heartbeats not from our target system'''
self.set_parameter("SIM_SPEEDUP", test.speedup)
test_function(**test_kwargs)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
# reset the message hooks; we've failed-via-exception and
@@ -9173,7 +9173,7 @@ Also, ignores heartbeats not from our target system'''
try:
self.wait_heartbeat()
ardupilot_alive = True
except Exception:
except Exception: # noqa: BLE001
# process is dead
self.progress("No heartbeat after test", send_statustext=False)
self.dump_process_status(result)
@@ -9183,7 +9183,7 @@ Also, ignores heartbeats not from our target system'''
try:
self.context_pop(process_interaction_allowed=ardupilot_alive, hooks_already_removed=hooks_removed)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e, send_statustext=False)
passed = False
@@ -9239,7 +9239,7 @@ Also, ignores heartbeats not from our target system'''
while len(self.contexts) > old_contexts_length:
try:
self.context_pop(process_interaction_allowed=ardupilot_alive, hooks_already_removed=hooks_removed)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e, send_statustext=False)
self.progress("Done popping extra contexts")
@@ -10219,7 +10219,7 @@ Also, ignores heartbeats not from our target system'''
do_prep_mag_cal_test(mavproxy, curr_params)
do_test_mag_cal(mavproxy, curr_params, ntest_compass)
except Exception as e:
except Exception as e: # noqa: BLE001
self.progress("Caught exception: %s" %
self.get_exception_stacktrace(e))
ex = e
@@ -10580,7 +10580,7 @@ Also, ignores heartbeats not from our target system'''
self.reboot_sitl()
self.wait_ready_to_arm(timeout=60)
except Exception as e:
except Exception as e: # noqa: BLE001
ex = e
self.context_pop()
@@ -10626,7 +10626,7 @@ Also, ignores heartbeats not from our target system'''
raise NotAchievedException("Exceptionally low transfer rate (%u < %u)" % (rate, desired_rate))
self.disarm_vehicle()
mavproxy.send('repeat remove 0\n')
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
self.disarm_vehicle()
ex = e
@@ -10710,7 +10710,7 @@ Also, ignores heartbeats not from our target system'''
mavproxy.send("log erase\n")
mavproxy.expect("Chip erase complete")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
mavproxy.send("module unload log\n")
@@ -10741,7 +10741,7 @@ Also, ignores heartbeats not from our target system'''
m = mlog.recv_match()
if m is None:
break
except Exception as e:
except Exception as e: # noqa: BLE001
raise NotAchievedException("Error reading log file %s: %s" % (logname, str(e)))
herrors = 0
@@ -10821,7 +10821,7 @@ Also, ignores heartbeats not from our target system'''
mavproxy.send("log erase\n")
mavproxy.expect("Chip erase complete")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -11309,7 +11309,7 @@ Also, ignores heartbeats not from our target system'''
self.set_message_rate_hz(message, rate)
for message in messages:
self.assert_message_rate_hz(message, rate)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -11376,7 +11376,7 @@ Also, ignores heartbeats not from our target system'''
if m.result != mavutil.mavlink.MAV_RESULT_FAILED:
raise NotAchievedException("Getting rate of unsupported message is a failure")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -11530,7 +11530,7 @@ Also, ignores heartbeats not from our target system'''
self.wait_statustext("Config error", wallclock_timeout=True)
self.progress("Setting %s to %f" % (parameter_name, new_parameter_value))
self.set_parameter(parameter_name, new_parameter_value)
except Exception as e:
except Exception as e: # noqa: BLE001
ex = e
self.progress("Resetting SIM_BARO_COUNT")
@@ -12925,7 +12925,7 @@ switch value'''
self.context_pop()
self.set_parameter("AFS_TERMINATE", 0)
except Exception as e:
except Exception as e: # noqa: BLE001
ex = e
try:
self.do_fence_disable()
@@ -13084,7 +13084,7 @@ switch value'''
(v, pname, expected_v, error_pct))
else:
self.progress("Correct value %.4f for %s error %.2f%%" % (v, pname, error_pct))
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.mavproxy_unload_module(mavproxy, "relay")
@@ -14459,7 +14459,7 @@ switch value'''
self.progress("Writing vtx_unknown")
crsf.write_data_id(crsf.dataid_vtx_unknown)
self.delay_sim_time(5)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
self.context_pop()
@@ -14731,12 +14731,12 @@ switch value'''
try:
mavproxy.expect("No transfer in progress", timeout=1)
break
except Exception:
except Exception: # noqa: BLE001
continue
# terminate the connection, or it may still be in progress the next time an FTP is attempted:
mavproxy.send("ftp cancel\n")
mavproxy.expect("Terminated session")
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
@@ -14764,7 +14764,7 @@ switch value'''
raise NotAchievedException("No directories?!")
expected_line = " D %s" % some_directory
mavproxy.expect(expected_line) # one line from the ftp list output
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
ex = e
+1 -1
View File
@@ -405,7 +405,7 @@ def main():
update_parameter_documentation(doc_dict, args.target, args.sort)
if args.verbose:
print_read_only_params(doc_dict)
except Exception as exp: # pylint: disable=W0718
except Exception as exp: # pylint: disable=W0718 # noqa: BLE001
logging.fatal(exp)
exit(1) # pylint: disable=R1722
+1 -1
View File
@@ -82,7 +82,7 @@ Options:
base = 16
try:
offset = int(a, base)
except:
except ValueError:
raise getopt.GetoptError('Bad offset value')
if not args:
+3 -3
View File
@@ -503,7 +503,7 @@ is bob we will attempt to checkout bob-AVR'''
if os.path.exists(ef_path):
try:
features_text = self.run_program("EF", [ef_path, bare_path], show_output=False)
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
self.progress("Failed to extract features")
pass
@@ -549,7 +549,7 @@ is bob we will attempt to checkout bob-AVR'''
self.progress("Writing (%s)" % features_filepath)
self.write_string_to_filepath(features_text, features_filepath)
shutil.copy(path, os.path.join(tdir, target_filename))
except Exception as e:
except Exception as e: # noqa: BLE001
self.print_exception_caught(e)
self.progress("Failed to copy %s to %s: %s" % (path, tdir, str(e)))
# why is touching this important? -pb20170816
@@ -575,7 +575,7 @@ is bob we will attempt to checkout bob-AVR'''
def get_exception_stacktrace(self, e):
try:
return self._get_exception_stacktrace(e)
except Exception:
except Exception: # noqa: BLE001 — defensive wrapper, must not raise
return "FAILED TO GET EXCEPTION STACKTRACE"
def print_exception_caught(self, e, send_statustext=True):
+1 -1
View File
@@ -88,7 +88,7 @@ class BuildScriptBase:
path = pathlib.Path(self.tmpdir, f"process-failure-{int(time.time())}")
path.write_text(process_failure_content)
self.progress("Wrote process failure file (%s)" % path)
except Exception:
except Exception: # noqa: BLE001 — best-effort debug-file write
self.progress("Writing process failure file failed")
raise subprocess.CalledProcessError(
returncode, cmd_list)
+1 -1
View File
@@ -31,7 +31,7 @@ def check_fw_version(version):
try:
(version_numbers, release_type) = version.split("-")
(_, _, _) = version_numbers.split(".")
except Exception:
except ValueError:
return False
return True
+5 -5
View File
@@ -349,7 +349,7 @@ class ManifestGenerator():
return
try:
dlist = os.listdir(dir)
except Exception:
except OSError:
print("Error listing '%s'" % dir)
return
for platformdir in dlist:
@@ -364,12 +364,12 @@ class ManifestGenerator():
continue
try:
git_sha = self.git_sha_from_git_version(git_version_txt)
except Exception as ex:
except Exception as ex: # noqa: BLE001
print("Failed to parse %s" % git_version_txt, ex, file=sys.stderr)
continue
try:
fwversion_str = self.fwversion_from_git_version(git_version_txt)
except Exception as ex:
except Exception as ex: # noqa: BLE001
print("Failed to parse APMVERSION %s" % git_version_txt, ex, file=sys.stderr)
continue
@@ -388,7 +388,7 @@ class ManifestGenerator():
except ValueError:
print("malformed firmware-version.txt at (%s)" % (firmware_version_file,), file=sys.stderr)
continue
except Exception:
except OSError:
print("bad file %s" % firmware_version_file, file=sys.stderr)
# this exception is swallowed.... the current archive
# is incomplete.
@@ -551,7 +551,7 @@ class ManifestGenerator():
try:
(major, minor, patch, release_type) = self.parse_fw_version(
firmware["firmware-version"])
except Exception:
except ValueError:
print("Badly formed firmware-version.txt %s" % firmware["firmware-version"], file=sys.stderr)
continue
some_json["mav-firmware-version"] = ".".join([major,
+1 -1
View File
@@ -104,7 +104,7 @@ class SizeHistory(BuildScriptBase):
from extract_features import ExtractFeatures
ef = ExtractFeatures(elf_path)
(features_in, features_not_in) = ef.extract()
except Exception as ex:
except Exception as ex: # noqa: BLE001
self.progress("Feature extraction failed: %s" % str(ex))
features_in = set()
+1 -1
View File
@@ -13,7 +13,7 @@ import time
try:
import argcomplete
except:
except ImportError:
pass
SYSTEM_RESET = struct.pack('B' * 4, 0x5A, 0x04, 0x02, 0x60)
+10 -10
View File
@@ -712,7 +712,7 @@ class uploader(object):
try:
report_crc = self.__recv_int()
break
except Exception:
except Exception: # noqa: BLE001
continue
if time.time() >= deadline:
@@ -741,7 +741,7 @@ class uploader(object):
else:
try:
self.extf_maxsize = self.__getInfo(uploader.INFO_EXTF_SIZE)
except Exception:
except Exception: # noqa: BLE001
print("Could not get external flash size, assuming 0")
self.extf_maxsize = 0
self.__sync()
@@ -754,7 +754,7 @@ class uploader(object):
# Only run if we are trying to identify the board
try:
self.git_hash_bl = self.__getBootloaderSoftware()
except Exception:
except Exception: # noqa: BLE001
self.__sync()
def dump_board_info(self):
@@ -786,7 +786,7 @@ class uploader(object):
x = x[::-1] # reverse the bytes
print(binascii.hexlify(x).decode('Latin-1'), end='') # show user
print('')
except Exception:
except Exception: # noqa: BLE001
# ignore bad character encodings
pass
@@ -901,7 +901,7 @@ class uploader(object):
if len(ret) == 0:
return None
return " or ".join(ret)
except Exception as e:
except Exception as e: # noqa: BLE001
print("Failed to get name: %s" % str(e))
return None
@@ -985,7 +985,7 @@ class uploader(object):
try:
self.port.baudrate = self.baudrate_flightstack[self.baudrate_flightstack_idx]
except Exception:
except Exception: # noqa: BLE001
return False
return True
@@ -1011,11 +1011,11 @@ class uploader(object):
self.__send(uploader.NSH_REBOOT)
self.port.flush()
self.port.baudrate = self.baudrate_bootloader
except Exception:
except Exception: # noqa: BLE001
try:
self.port.flush()
self.port.baudrate = self.baudrate_bootloader
except Exception:
except Exception: # noqa: BLE001
pass
return True
@@ -1089,7 +1089,7 @@ def find_bootloader(up, port):
print("Found board %x,%x bootloader rev %x on %s" % (up.board_type, up.board_rev, up.bl_rev, port))
return True
except Exception:
except Exception: # noqa: BLE001
pass
reboot_sent = up.send_reboot()
@@ -1204,7 +1204,7 @@ def main():
args.force_erase,
args.identify)
except Exception as e:
except Exception as e: # noqa: BLE001
if not is_WSL and not is_WSL2 and "win32" not in _platform:
# open failed, WSL must cycle through all ttyS* ports quickly but rate limit everything else
print("Exception creating uploader: %s" % str(e))