mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Support 505s with a BCD of 0x1000 on windows and linux
This commit is contained in:
parent
99993e492e
commit
462124c87b
@ -24,12 +24,12 @@ class PRS505(CLI, Device):
|
|||||||
|
|
||||||
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
VENDOR_ID = [0x054c] #: SONY Vendor Id
|
||||||
PRODUCT_ID = [0x031e] #: Product Id for the PRS-505
|
PRODUCT_ID = [0x031e] #: Product Id for the PRS-505
|
||||||
BCD = [0x229] #: Needed to disambiguate 505 and 700 on linux
|
BCD = [0x229, 0x1000] #: Needed to disambiguate 505 and 700 on linux
|
||||||
|
|
||||||
VENDOR_NAME = 'SONY'
|
VENDOR_NAME = 'SONY'
|
||||||
WINDOWS_MAIN_MEM = 'PRS-505'
|
WINDOWS_MAIN_MEM = 'PRS-505'
|
||||||
WINDOWS_CARD_A_MEM = 'PRS-505/UC:MS'
|
WINDOWS_CARD_A_MEM = ['PRS-505/UC:MS', 'PRS-505/CE:MS']
|
||||||
WINDOWS_CARD_B_MEM = 'PRS-505/UC:SD'
|
WINDOWS_CARD_B_MEM = ['PRS-505/UC:SD', 'PRS-505/CE:SD']
|
||||||
|
|
||||||
OSX_MAIN_MEM = 'Sony PRS-505/UC Media'
|
OSX_MAIN_MEM = 'Sony PRS-505/UC Media'
|
||||||
OSX_CARD_A_MEM = 'Sony PRS-505/UC:MS Media'
|
OSX_CARD_A_MEM = 'Sony PRS-505/UC:MS Media'
|
||||||
|
@ -179,13 +179,19 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
return (msz, casz, cbsz)
|
return (msz, casz, cbsz)
|
||||||
|
|
||||||
def windows_match_device(self, pnp_id, device_id):
|
def windows_match_device(self, drive, attr):
|
||||||
pnp_id = pnp_id.upper()
|
pnp_id = str(drive.PNPDeviceID).upper()
|
||||||
|
device_id = getattr(self, attr)
|
||||||
|
if device_id is None or \
|
||||||
|
'VEN_' + str(self.VENDOR_NAME).upper() not in pnp_id:
|
||||||
|
return False
|
||||||
|
if isinstance(device_id, basestring):
|
||||||
|
device_id = [device_id]
|
||||||
|
|
||||||
if device_id and pnp_id is not None:
|
for x in device_id:
|
||||||
device_id = device_id.upper()
|
x = x.upper()
|
||||||
|
|
||||||
if 'VEN_' + self.VENDOR_NAME in pnp_id and 'PROD_' + device_id in pnp_id:
|
if 'PROD_' + x in pnp_id:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@ -211,18 +217,32 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
return drives
|
return drives
|
||||||
|
|
||||||
def open_windows(self):
|
def open_windows(self):
|
||||||
|
|
||||||
|
def matches_q(drive, attr):
|
||||||
|
q = getattr(self, attr)
|
||||||
|
if q is None: return False
|
||||||
|
if isinstance(q, basestring):
|
||||||
|
q = [q]
|
||||||
|
pnp = str(drive.PNPDeviceID)
|
||||||
|
for x in q:
|
||||||
|
if x in pnp:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
time.sleep(6)
|
time.sleep(6)
|
||||||
drives = {}
|
drives = {}
|
||||||
wmi = __import__('wmi', globals(), locals(), [], -1)
|
wmi = __import__('wmi', globals(), locals(), [], -1)
|
||||||
c = wmi.WMI(find_classes=False)
|
c = wmi.WMI(find_classes=False)
|
||||||
for drive in c.Win32_DiskDrive():
|
for drive in c.Win32_DiskDrive():
|
||||||
if self.windows_match_device(str(drive.PNPDeviceID), self.WINDOWS_CARD_A_MEM):
|
if self.windows_match_device(drive, 'WINDOWS_CARD_A_MEM'):
|
||||||
drives['carda'] = self.windows_get_drive_prefix(drive)
|
drives['carda'] = self.windows_get_drive_prefix(drive)
|
||||||
elif self.windows_match_device(str(drive.PNPDeviceID), self.WINDOWS_CARD_B_MEM):
|
elif self.windows_match_device(drive, 'WINDOWS_CARD_B_MEM'):
|
||||||
drives['cardb'] = self.windows_get_drive_prefix(drive)
|
drives['cardb'] = self.windows_get_drive_prefix(drive)
|
||||||
elif self.windows_match_device(str(drive.PNPDeviceID), self.WINDOWS_MAIN_MEM):
|
elif self.windows_match_device(drive, 'WINDOWS_MAIN_MEM'):
|
||||||
drives['main'] = self.windows_get_drive_prefix(drive)
|
drives['main'] = self.windows_get_drive_prefix(drive)
|
||||||
if 'main' in drives.keys() and 'carda' in drives.keys() and 'cardb' in drives.keys():
|
if 'main' in drives.keys() and 'carda' in drives.keys() and \
|
||||||
|
'cardb' in drives.keys():
|
||||||
break
|
break
|
||||||
|
|
||||||
if 'main' not in drives:
|
if 'main' not in drives:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user