From 2a583c3a754ebf8b3fa51df1da840b16b27e35dc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Feb 2008 16:38:19 +0000 Subject: [PATCH] Make partition detection code on windows a little more robust --- src/libprs500/devices/kindle/driver.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libprs500/devices/kindle/driver.py b/src/libprs500/devices/kindle/driver.py index 260b740bf5..0b05c80bd8 100755 --- a/src/libprs500/devices/kindle/driver.py +++ b/src/libprs500/devices/kindle/driver.py @@ -100,6 +100,8 @@ class KINDLE(Device): @classmethod def is_device(cls, device_id): '''print "mimi in is device"''' + if not hasattr(device_id, 'upper'): + return False if 'VEN_'+cls.VENDOR_NAME in device_id.upper() and \ 'PROD_'+cls.INTERNAL_STORAGE in device_id.upper(): @@ -153,11 +155,12 @@ class KINDLE(Device): continue try: partition = drive.associators("Win32_DiskDriveToDiskPartition")[0] + logical_disk = partition.associators('Win32_LogicalDiskToPartition')[0] + prefix = logical_disk.DeviceID+os.sep + drives.append((drive.Index, prefix)) except IndexError: continue - logical_disk = partition.associators('Win32_LogicalDiskToPartition')[0] - prefix = logical_disk.DeviceID+os.sep - drives.append((drive.Index, prefix)) + if not drives: print self.__class__.__name__