mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make user_defined_device information work on linux
This commit is contained in:
parent
f74bed6381
commit
0962ebb3ba
@ -162,14 +162,28 @@ def device_info(ioreg_to_tmp=False, buf=None):
|
||||
import re
|
||||
|
||||
res = {}
|
||||
if not iswindows:
|
||||
return None
|
||||
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
|
||||
|
||||
try:
|
||||
s = DeviceScanner()
|
||||
s.scan()
|
||||
devices = (s.devices)
|
||||
device_details = {}
|
||||
device_set = set()
|
||||
if not iswindows:
|
||||
devices = [list(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:
|
||||
@ -183,11 +197,8 @@ def device_info(ioreg_to_tmp=False, buf=None):
|
||||
d = vid+pid+rev
|
||||
device_set.add(d)
|
||||
device_details[d] = (vid, pid, rev)
|
||||
res['device_set'] = device_set
|
||||
res['device_details'] = device_details
|
||||
|
||||
drives = win_pnp_drives(debug=False)
|
||||
drive_details = {}
|
||||
drive_set = set()
|
||||
for drive,details in drives.iteritems():
|
||||
order = 'ORD_' + str(drive.order)
|
||||
ven = re.search('VEN_([^&]*)&', details)
|
||||
@ -199,8 +210,6 @@ def device_info(ioreg_to_tmp=False, buf=None):
|
||||
d = (order, ven, prod)
|
||||
drive_details[drive] = d
|
||||
drive_set.add(drive)
|
||||
res['drive_details'] = drive_details
|
||||
res['drive_set'] = drive_set
|
||||
finally:
|
||||
pass
|
||||
return res
|
@ -10,6 +10,8 @@ __docformat__ = 'restructuredtext en'
|
||||
from PyQt4.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)
|
||||
@ -26,10 +28,10 @@ class UserDefinedDevice(QDialog):
|
||||
self.setLayout(self._layout)
|
||||
self.log = QPlainTextEdit(self)
|
||||
self._layout.addWidget(self.log)
|
||||
self.log.setPlainText(_('Getting debug information')+'...')
|
||||
self.log.setPlainText(_('Getting device information')+'...')
|
||||
self.copy = QPushButton(_('Copy to &clipboard'))
|
||||
self.copy.setDefault(True)
|
||||
self.setWindowTitle(_('Debug device detection'))
|
||||
self.setWindowTitle(_('User-defined device information'))
|
||||
self.setWindowIcon(QIcon(I('debug.png')))
|
||||
self.copy.clicked.connect(self.copy_to_clipboard)
|
||||
self.ok = QPushButton('&OK')
|
||||
@ -59,7 +61,7 @@ class UserDefinedDevice(QDialog):
|
||||
new_drives = after['drive_set'] - before['drive_set']
|
||||
new_devices = after['device_set'] - before['device_set']
|
||||
res = ''
|
||||
if len(new_drives) and len(new_devices) == 1:
|
||||
if (not iswindows or len(new_drives)) and len(new_devices) == 1:
|
||||
for d in new_devices:
|
||||
res = _('USB Vendor ID (in hex)') + ': 0x' + \
|
||||
after['device_details'][d][0] + '\n'
|
||||
@ -67,6 +69,7 @@ class UserDefinedDevice(QDialog):
|
||||
after['device_details'][d][1] + '\n'
|
||||
res += _('USB Revision ID (in hex)') + ': 0x' + \
|
||||
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])):
|
||||
@ -80,7 +83,6 @@ class UserDefinedDevice(QDialog):
|
||||
after['drive_details'][d][1] + '\n'
|
||||
res += _('Windows card A ID string') + ': ' + \
|
||||
after['drive_details'][d][2] + '\n'
|
||||
|
||||
trailer = _('Enter the above values into the USER_DEVICE by '
|
||||
'customizing the device plugin. Be sure to also '
|
||||
'enter the folders where you want the books to '
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
||||
from calibre.gui2.preferences.misc_ui import Ui_Form
|
||||
from calibre.gui2 import error_dialog, config, open_local_file, info_dialog
|
||||
from calibre.constants import isosx, iswindows
|
||||
from calibre.constants import isosx
|
||||
|
||||
class WorkersSetting(Setting):
|
||||
|
||||
@ -33,7 +33,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.user_defined_device_button.clicked.connect(self.user_defined_device)
|
||||
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
||||
self.button_osx_symlinks.setVisible(isosx)
|
||||
self.user_defined_device_button.setVisible(iswindows)
|
||||
|
||||
def debug_device_detection(self, *args):
|
||||
from calibre.gui2.preferences.device_debug import DebugDevice
|
||||
|
@ -61,7 +61,7 @@
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="user_defined_device_button">
|
||||
<property name="text">
|
||||
<string>Get information to setup the &user defined device (Windows only)</string>
|
||||
<string>Get information to setup the &user defined device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user