Skip to content

Commit

Permalink
fix NoneType error due to bad returns in win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Neradoc committed Dec 8, 2022
1 parent 49da760 commit 5b0155a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions discotool/usbinfos/usb_descriptor_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_str_desc(handle, conn_idx, str_idx):
def exam_hub(name, level, location):
handle = open_dev(r'\\.\{}'.format(name))
if not handle:
return
return []
buf = win32file.DeviceIoControl(handle,
IOCTL_USB_GET_NODE_INFORMATION,
None,
Expand All @@ -177,12 +177,17 @@ def get_hub_ports(handle, num_ports, level, location):
None)
except pywintypes.error as e:
# print(e.winerror, e.funcname, e.strerror)
return
pass

_, vid, pid, vers, manu, prod, seri, _, ishub, _, stat = struct.unpack('=12sHHHBBB3s?6sL', buf[:35])

if ishub:
devices += exam_hub(get_ext_hub_name(handle, idx), level + 1, location + (idx,))
try:
examed = exam_hub(get_ext_hub_name(handle, idx), level + 1, location + (idx,))
if examed:
devices += examed
except TypeError as ex:
pass
elif stat == 1:
if (manu != 0 or prod != 0 or seri != 0):
# print('{} [Port{}] {}'.format(' '*level, idx, get_driverkey_name(handle, idx)))
Expand Down

0 comments on commit 5b0155a

Please sign in to comment.