config-tools: board inspector does not exit if a usb device is unplugged

Board inspector may throw an error if a usb device is unplugged or
disconnected while extracting usb device information. Print out the
debug message and continue parsing.

Tracked-On: #8325
Signed-off-by: yuchuyang <yu-chu.yang@intel.com>
Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
yuchuyang 2022-11-14 13:43:05 -08:00 committed by acrnsi-robot
parent b02f991423
commit 9d8ddeabdc
1 changed files with 17 additions and 14 deletions

View File

@ -3,7 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#
import os, re
import os, re, logging
from extractors.helpers import add_child, get_node
@ -17,6 +17,7 @@ def extract(args, board_etree):
if m:
d = m.group(0)
devpath = os.path.join(USB_DEVICES_PATH, d)
try:
with open(os.path.join(devpath, 'devnum'), 'r') as f:
devnum = f.read().strip()
with open(os.path.join(devpath, 'busnum'), 'r') as f:
@ -30,4 +31,6 @@ def extract(args, board_etree):
if usb_port_node is not None:
add_child(usb_port_node, "usb_device", location=d,
description=d + desc)
except Exception as e:
logging.debug(f"{e}: please check if a USB device has been removed form usb port {d}.")
pass