Fix for bug in windows detection of BeBook

This commit is contained in:
Kovid Goyal 2009-05-11 07:25:58 -07:00
parent aeae9e613a
commit 04d8e251c5

View File

@ -47,8 +47,8 @@ class DeviceScanner(object):
rev = ('rev_%4.4x'%c).replace('a', ':') rev = ('rev_%4.4x'%c).replace('a', ':')
if rev in device_id: if rev in device_id:
return True return True
return False return False
def test_bcd(self, bcdDevice, bcd): def test_bcd(self, bcdDevice, bcd):
if bcd is None or len(bcd) == 0: if bcd is None or len(bcd) == 0:
return True return True
@ -56,19 +56,20 @@ class DeviceScanner(object):
if c == bcdDevice: if c == bcdDevice:
return True return True
return False return False
def is_device_connected(self, device): def is_device_connected(self, device):
vendor_ids = device.VENDOR_ID if hasattr(device.VENDOR_ID, '__len__') else [device.VENDOR_ID] vendor_ids = device.VENDOR_ID if hasattr(device.VENDOR_ID, '__len__') else [device.VENDOR_ID]
product_ids = device.PRODUCT_ID if hasattr(device.PRODUCT_ID, '__len__') else [device.PRODUCT_ID] product_ids = device.PRODUCT_ID if hasattr(device.PRODUCT_ID, '__len__') else [device.PRODUCT_ID]
if iswindows: if iswindows:
for vendor_id, product_id in zip(vendor_ids, product_ids): for vendor_id in vendor_ids:
vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id for product_id in product_ids:
vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id
for device_id in self.devices: vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id
if (vid in device_id or vidd in device_id) and (pid in device_id or pidd in device_id): for device_id in self.devices:
if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)): if (vid in device_id or vidd in device_id) and (pid in device_id or pidd in device_id):
if device.can_handle(device_id): if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)):
return True if device.can_handle(device_id):
return True
else: else:
for vendor, product, bcdDevice in self.devices: for vendor, product, bcdDevice in self.devices:
if vendor in vendor_ids and product in product_ids: if vendor in vendor_ids and product in product_ids: