Running mbed-tools detect
on mac_os fails when a USB peripheral does not provide some data
#333
Labels
bug
Something isn't working
Describe the bug
Running
mbed-tools detect
on mac_os fails when a USB peripheral (i.e. my USB mouse) does not provide some data (in my case, there is novendor_id
in the USB device properties)To Reproduce
Steps to reproduce the behavior:
vendor_id
(for example, verify which info are provided by USB peripherals by runningsystem_profiler SPUSBDataType
)mbed-tools detect
IndexError: list index out of range
Expected behavior
mbed-tools detect
should discard the USB peripheral with missing info, if they are necessary to detect the board, instead of throwing an errorDesktop (please complete the following information):
Mbed (please complete the following information):
Additional context
in file
mbed_tools/devices/_internal/darwin/device_detector.py
in function
_assemble_candidate_data
the line
device_data.get("vendor_id", "")
produces a crash when the vendor_id is not provided by the peripheral(I expect the same possible issue with the next two lines, using the same method to get "product_id" and "serial_num")
Traceback (most recent call last):
File "/myProject/bin/mbed-tools", line 8, in
sys.exit(cli())
File "/myProject/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/myProject/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/myProject/lib/python3.10/site-packages/mbed_tools/cli/main.py", line 38, in invoke
super().invoke(context)
File "/myProject/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/myProject/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/myProject/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/myProject/lib/python3.10/site-packages/mbed_tools/cli/list_connected_devices.py", line 29, in list_connected_devices
connected_devices = get_connected_devices()
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/devices.py", line 24, in get_connected_devices
for candidate_device in detect_candidate_devices():
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/_internal/detect_candidate_devices.py", line 17, in detect_candidate_devices
return detector.find_candidates()
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/_internal/darwin/device_detector.py", line 45, in find_candidates
candidate = _build_candidate(device_data)
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/_internal/darwin/device_detector.py", line 55, in _build_candidate
assembled_data = _assemble_candidate_data(device_data)
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/_internal/darwin/device_detector.py", line 65, in _assemble_candidate_data
"vendor_id": _format_vendor_id(device_data.get("vendor_id", "")),
File "/myProject/lib/python3.10/site-packages/mbed_tools/devices/_internal/darwin/device_detector.py", line 79, in _format_vendor_id
return vendor_id.split(maxsplit=1)[0]
IndexError: list index out of range
The text was updated successfully, but these errors were encountered: