From 04d8e251c5bfb9763f75e529a62e75f18551712f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 May 2009 07:25:58 -0700 Subject: [PATCH] Fix for bug in windows detection of BeBook --- src/calibre/devices/scanner.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/calibre/devices/scanner.py b/src/calibre/devices/scanner.py index a93ef54c32..c73b1cd2f6 100644 --- a/src/calibre/devices/scanner.py +++ b/src/calibre/devices/scanner.py @@ -47,8 +47,8 @@ class DeviceScanner(object): rev = ('rev_%4.4x'%c).replace('a', ':') if rev in device_id: return True - return False - + return False + def test_bcd(self, bcdDevice, bcd): if bcd is None or len(bcd) == 0: return True @@ -56,19 +56,20 @@ class DeviceScanner(object): if c == bcdDevice: return True return False - + def is_device_connected(self, device): 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] if iswindows: - for vendor_id, product_id in zip(vendor_ids, product_ids): - vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id - vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id - for device_id in self.devices: - if (vid in device_id or vidd in device_id) and (pid in device_id or pidd in device_id): - if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)): - if device.can_handle(device_id): - return True + for vendor_id in vendor_ids: + for product_id in product_ids: + vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id + vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id + for device_id in self.devices: + if (vid in device_id or vidd in device_id) and (pid in device_id or pidd in device_id): + if self.test_bcd_windows(device_id, getattr(device, 'BCD', None)): + if device.can_handle(device_id): + return True else: for vendor, product, bcdDevice in self.devices: if vendor in vendor_ids and product in product_ids: