Make partition detection code on windows a little more robust

This commit is contained in:
Kovid Goyal 2008-02-13 19:02:30 +00:00
parent fc4c746554
commit 6a4aec5fa5

View File

@ -100,14 +100,17 @@ class PRS505(Device):
@classmethod @classmethod
def is_device(cls, device_id): def is_device(cls, device_id):
if 'VEN_'+cls.VENDOR_NAME in device_id.upper() and \ if not hasattr(device_id, 'upper'):
'PROD_'+cls.PRODUCT_NAME in device_id.upper(): return False
device_id = device_id.upper()
if 'VEN_'+cls.VENDOR_NAME in device_id and \
'PROD_'+cls.PRODUCT_NAME in device_id:
return True return True
vid, pid = hex(cls.VENDOR_ID)[2:], hex(cls.PRODUCT_ID)[2:] vid, pid = hex(cls.VENDOR_ID)[2:], hex(cls.PRODUCT_ID)[2:]
if len(vid) < 4: vid = '0'+vid if len(vid) < 4: vid = '0'+vid
if len(pid) < 4: pid = '0'+pid if len(pid) < 4: pid = '0'+pid
if 'VID_'+vid in device_id.upper() and \ if 'VID_'+vid in device_id and \
'PID_'+pid in device_id.upper(): 'PID_'+pid in device_id:
return True return True
return False return False