mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Forgot to update the user defined device driver to work with the new windows device detection
This commit is contained in:
parent
dfd3be5b56
commit
1c580d1eba
@ -194,59 +194,17 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
pass
|
||||
|
||||
def device_info(ioreg_to_tmp=False, buf=None):
|
||||
from calibre.devices.scanner import DeviceScanner, win_pnp_drives
|
||||
from calibre.constants import iswindows
|
||||
import re
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
|
||||
res = {}
|
||||
device_details = {}
|
||||
device_set = set()
|
||||
drive_details = {}
|
||||
drive_set = set()
|
||||
res['device_set'] = device_set
|
||||
res['device_details'] = device_details
|
||||
res['drive_details'] = drive_details
|
||||
res['drive_set'] = drive_set
|
||||
res['device_set'] = device_set = set()
|
||||
res['device_details'] = device_details = {}
|
||||
|
||||
try:
|
||||
s = DeviceScanner()
|
||||
s.scan()
|
||||
devices = (s.devices)
|
||||
if not iswindows:
|
||||
devices = [list(x) for x in devices]
|
||||
devices = s.devices
|
||||
devices = [tuple(x) for x in devices]
|
||||
for dev in devices:
|
||||
for i in range(3):
|
||||
dev[i] = hex(dev[i])
|
||||
d = dev[0] + dev[1] + dev[2]
|
||||
device_set.add(d)
|
||||
device_details[d] = dev[0:3]
|
||||
else:
|
||||
for dev in devices:
|
||||
vid = re.search('vid_([0-9a-f]*)&', dev)
|
||||
if vid:
|
||||
vid = vid.group(1)
|
||||
pid = re.search('pid_([0-9a-f]*)&', dev)
|
||||
if pid:
|
||||
pid = pid.group(1)
|
||||
rev = re.search('rev_([0-9a-f]*)$', dev)
|
||||
if rev:
|
||||
rev = rev.group(1)
|
||||
d = vid+pid+rev
|
||||
device_set.add(d)
|
||||
device_details[d] = (vid, pid, rev)
|
||||
|
||||
drives = win_pnp_drives(debug=False)
|
||||
for drive,details in drives.iteritems():
|
||||
order = 'ORD_' + str(drive.order)
|
||||
ven = re.search('VEN_([^&]*)&', details)
|
||||
if ven:
|
||||
ven = ven.group(1)
|
||||
prod = re.search('PROD_([^&]*)&', details)
|
||||
if prod:
|
||||
prod = prod.group(1)
|
||||
d = (order, ven, prod)
|
||||
drive_details[drive] = d
|
||||
drive_set.add(drive)
|
||||
finally:
|
||||
pass
|
||||
device_set.add(dev)
|
||||
device_details[dev] = dev[0:3]
|
||||
return res
|
||||
|
@ -34,40 +34,32 @@ class USER_DEFINED(USBMS):
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
EXTRA_CUSTOMIZATION_MESSAGE = [
|
||||
_('USB Vendor ID (in hex)') + ':::<p>' +
|
||||
_('Get this ID using Preferences -> Misc -> Get information to '
|
||||
_('USB Vendor ID (in hex)') + ':::<p>' + _(
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('USB Product ID (in hex)')+ ':::<p>' +
|
||||
_('Get this ID using Preferences -> Misc -> Get information to '
|
||||
_('USB Product ID (in hex)')+ ':::<p>' + _(
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('USB Revision ID (in hex)')+ ':::<p>' +
|
||||
_('Get this ID using Preferences -> Misc -> Get information to '
|
||||
_('USB Revision ID (in hex)')+ ':::<p>' + _(
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
'',
|
||||
_('Windows main memory vendor string') + ':::<p>' +
|
||||
_('This field is used only on windows. '
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('Windows main memory ID string') + ':::<p>' +
|
||||
_('This field is used only on windows. '
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('Windows card A vendor string') + ':::<p>' +
|
||||
_('This field is used only on windows. '
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('Windows card A ID string') + ':::<p>' +
|
||||
_('This field is used only on windows. '
|
||||
'Get this ID using Preferences -> Misc -> Get information to '
|
||||
'set up the user-defined device') + '</p>',
|
||||
_('Main memory folder') + ':::<p>' +
|
||||
_('Enter the folder where the books are to be stored. This folder '
|
||||
_('Unused (leave blank)') + ':::<p>' + _(
|
||||
'This field is no longer used, leave it blank.') + '</p>',
|
||||
_('Unused (leave blank)') + ':::<p>' + _(
|
||||
'This field is no longer used, leave it blank.') + '</p>',
|
||||
_('Unused (leave blank)') + ':::<p>' + _(
|
||||
'This field is no longer used, leave it blank.') + '</p>',
|
||||
_('Unused (leave blank)') + ':::<p>' + _(
|
||||
'This field is no longer used, leave it blank.') + '</p>',
|
||||
_('Main memory folder') + ':::<p>' + _(
|
||||
'Enter the folder where the books are to be stored. This folder '
|
||||
'is prepended to any send_to_device template') + '</p>',
|
||||
_('Card A folder') + ':::<p>' +
|
||||
_('Enter the folder where the books are to be stored. This folder '
|
||||
_('Card A folder') + ':::<p>' + _(
|
||||
'Enter the folder where the books are to be stored. This folder '
|
||||
'is prepended to any send_to_device template') + '</p>',
|
||||
_('Swap main and card A') + ':::<p>' +
|
||||
_('Check this box if the device\'s main memory is being seen as '
|
||||
_('Swap main and card A') + ':::<p>' + _(
|
||||
'Check this box if the device\'s main memory is being seen as '
|
||||
'card a and the card is being seen as main memory') + '</p>',
|
||||
]
|
||||
EXTRA_CUSTOMIZATION_DEFAULT = [
|
||||
|
@ -10,8 +10,6 @@ __docformat__ = 'restructuredtext en'
|
||||
from PyQt5.Qt import QDialog, QVBoxLayout, QPlainTextEdit, QTimer, \
|
||||
QDialogButtonBox, QPushButton, QApplication, QIcon, QMessageBox
|
||||
|
||||
from calibre.constants import iswindows
|
||||
|
||||
def step_dialog(parent, title, msg, det_msg=''):
|
||||
d = QMessageBox(parent)
|
||||
d.setWindowTitle(title)
|
||||
@ -60,11 +58,12 @@ class UserDefinedDevice(QDialog):
|
||||
self.close()
|
||||
return
|
||||
after = device_info()
|
||||
new_drives = after['drive_set'] - before['drive_set']
|
||||
new_devices = after['device_set'] - before['device_set']
|
||||
res = ''
|
||||
if (not iswindows or len(new_drives)) and len(new_devices) == 1:
|
||||
if len(new_devices) == 1:
|
||||
def fmtid(x):
|
||||
if isinstance(x, (int, long)):
|
||||
x = hex(x)
|
||||
if not x.startswith('0x'):
|
||||
x = '0x' + x
|
||||
return x
|
||||
@ -76,20 +75,6 @@ class UserDefinedDevice(QDialog):
|
||||
fmtid(after['device_details'][d][1]) + '\n'
|
||||
res += _('USB Revision ID (in hex)') + ': ' + \
|
||||
fmtid(after['device_details'][d][2]) + '\n'
|
||||
if iswindows:
|
||||
# sort the drives by the order number
|
||||
for i,d in enumerate(sorted(new_drives,
|
||||
key=lambda x: after['drive_details'][x][0])):
|
||||
if i == 0:
|
||||
res += _('Windows main memory vendor string') + ': ' + \
|
||||
after['drive_details'][d][1] + '\n'
|
||||
res += _('Windows main memory ID string') + ': ' + \
|
||||
after['drive_details'][d][2] + '\n'
|
||||
else:
|
||||
res += _('Windows card A vendor string') + ': ' + \
|
||||
after['drive_details'][d][1] + '\n'
|
||||
res += _('Windows card A ID string') + ': ' + \
|
||||
after['drive_details'][d][2] + '\n'
|
||||
trailer = _(
|
||||
'Copy these values to the clipboard, paste them into an '
|
||||
'editor, then enter them into the USER_DEVICE by '
|
||||
|
Loading…
x
Reference in New Issue
Block a user