mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
255fe03b28
commit
f74bed6381
@ -159,7 +159,6 @@ def debug(ioreg_to_tmp=False, buf=None):
|
|||||||
def device_info(ioreg_to_tmp=False, buf=None):
|
def device_info(ioreg_to_tmp=False, buf=None):
|
||||||
from calibre.devices.scanner import DeviceScanner, win_pnp_drives
|
from calibre.devices.scanner import DeviceScanner, win_pnp_drives
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
from calibre import prints
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
@ -182,14 +181,12 @@ def device_info(ioreg_to_tmp=False, buf=None):
|
|||||||
if rev:
|
if rev:
|
||||||
rev = rev.group(1)
|
rev = rev.group(1)
|
||||||
d = vid+pid+rev
|
d = vid+pid+rev
|
||||||
prints(d)
|
|
||||||
device_set.add(d)
|
device_set.add(d)
|
||||||
device_details[d] = (vid, pid, rev)
|
device_details[d] = (vid, pid, rev)
|
||||||
res['device_set'] = device_set
|
res['device_set'] = device_set
|
||||||
res['device_details'] = device_details
|
res['device_details'] = device_details
|
||||||
drives = win_pnp_drives(debug=False)
|
drives = win_pnp_drives(debug=False)
|
||||||
drive_details = {}
|
drive_details = {}
|
||||||
print drives
|
|
||||||
drive_set = set()
|
drive_set = set()
|
||||||
for drive,details in drives.iteritems():
|
for drive,details in drives.iteritems():
|
||||||
order = 'ORD_' + str(drive.order)
|
order = 'ORD_' + str(drive.order)
|
||||||
@ -200,7 +197,6 @@ def device_info(ioreg_to_tmp=False, buf=None):
|
|||||||
if prod:
|
if prod:
|
||||||
prod = prod.group(1)
|
prod = prod.group(1)
|
||||||
d = (order, ven, prod)
|
d = (order, ven, prod)
|
||||||
print d
|
|
||||||
drive_details[drive] = d
|
drive_details[drive] = d
|
||||||
drive_set.add(drive)
|
drive_set.add(drive)
|
||||||
res['drive_details'] = drive_details
|
res['drive_details'] = drive_details
|
||||||
|
@ -10,7 +10,7 @@ from calibre.ebooks import BOOK_EXTENSIONS
|
|||||||
class USER_DEFINED(USBMS):
|
class USER_DEFINED(USBMS):
|
||||||
|
|
||||||
name = 'User Defined USB driver'
|
name = 'User Defined USB driver'
|
||||||
gui_name = 'User Defined phone'
|
gui_name = 'User Defined USB Device'
|
||||||
author = 'Kovid Goyal'
|
author = 'Kovid Goyal'
|
||||||
supported_platforms = ['windows', 'osx', 'linux']
|
supported_platforms = ['windows', 'osx', 'linux']
|
||||||
|
|
||||||
@ -66,21 +66,22 @@ class USER_DEFINED(USBMS):
|
|||||||
OPT_MAIN_MEM_FOLDER = 7
|
OPT_MAIN_MEM_FOLDER = 7
|
||||||
OPT_CARD_A_FOLDER = 8
|
OPT_CARD_A_FOLDER = 8
|
||||||
|
|
||||||
def __init__(self, *args):
|
def initialize(self):
|
||||||
USBMS.__init__(self, args)
|
|
||||||
try:
|
try:
|
||||||
e = self.settings().extra_customization
|
e = self.settings().extra_customization
|
||||||
self.VENDOR_ID = int(e[self.OPT_USB_VENDOR_ID], 16)
|
self.VENDOR_ID = int(e[self.OPT_USB_VENDOR_ID], 16)
|
||||||
self.PRODUCT_ID = int(e[self.OPT_USB_PRODUCT_ID], 16)
|
self.PRODUCT_ID = int(e[self.OPT_USB_PRODUCT_ID], 16)
|
||||||
self.BCD = [int(e[self.OPT_USB_REVISION_ID], 16)]
|
self.BCD = [int(e[self.OPT_USB_REVISION_ID], 16)]
|
||||||
print '%x, %x, %s' %(self.VENDOR_ID, self.PRODUCT_ID, str(self.BCD))
|
|
||||||
if e[self.OPT_USB_WINDOWS_MM_VEN_ID]:
|
if e[self.OPT_USB_WINDOWS_MM_VEN_ID]:
|
||||||
self.VENDOR_NAME.append(e[self.OPT_USB_WINDOWS_MM_VEN_ID])
|
self.VENDOR_NAME.append(e[self.OPT_USB_WINDOWS_MM_VEN_ID])
|
||||||
if e[self.OPT_USB_WINDOWS_CA_VEN_ID]:
|
if e[self.OPT_USB_WINDOWS_CA_VEN_ID] and \
|
||||||
|
e[self.OPT_USB_WINDOWS_CA_VEN_ID] not in self.VENDOR_NAME:
|
||||||
self.VENDOR_NAME.append(e[self.OPT_USB_WINDOWS_CA_VEN_ID])
|
self.VENDOR_NAME.append(e[self.OPT_USB_WINDOWS_CA_VEN_ID])
|
||||||
self.WINDOWS_MAIN_MEM = e[self.OPT_USB_WINDOWS_MM_ID]
|
self.WINDOWS_MAIN_MEM = e[self.OPT_USB_WINDOWS_MM_ID] + '&'
|
||||||
self.WINDOWS_CARD_A_MEM = e[self.OPT_USB_WINDOWS_CA_ID]
|
self.WINDOWS_CARD_A_MEM = e[self.OPT_USB_WINDOWS_CA_ID] + '&'
|
||||||
self.EBOOK_DIR_MAIN = e[self.OPT_MAIN_MEM_FOLDER]
|
self.EBOOK_DIR_MAIN = e[self.OPT_MAIN_MEM_FOLDER]
|
||||||
self.EBOOK_DIR_CARD_A = e[self.OPT_CARD_A_FOLDER]
|
self.EBOOK_DIR_CARD_A = e[self.OPT_CARD_A_FOLDER]
|
||||||
except:
|
except:
|
||||||
pass
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
USBMS.initialize(self)
|
@ -81,7 +81,12 @@ class UserDefinedDevice(QDialog):
|
|||||||
res += _('Windows card A ID string') + ': ' + \
|
res += _('Windows card A ID string') + ': ' + \
|
||||||
after['drive_details'][d][2] + '\n'
|
after['drive_details'][d][2] + '\n'
|
||||||
|
|
||||||
self.log.setPlainText(res)
|
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 '
|
||||||
|
'be put. You must restart calibre for your changes '
|
||||||
|
'to take effect.\n')
|
||||||
|
self.log.setPlainText(res + '\n\n' + trailer)
|
||||||
finally:
|
finally:
|
||||||
self.bbox.setEnabled(True)
|
self.bbox.setEnabled(True)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
||||||
from calibre.gui2.preferences.misc_ui import Ui_Form
|
from calibre.gui2.preferences.misc_ui import Ui_Form
|
||||||
from calibre.gui2 import error_dialog, config, open_local_file, info_dialog
|
from calibre.gui2 import error_dialog, config, open_local_file, info_dialog
|
||||||
from calibre.constants import isosx
|
from calibre.constants import isosx, iswindows
|
||||||
|
|
||||||
class WorkersSetting(Setting):
|
class WorkersSetting(Setting):
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.user_defined_device_button.clicked.connect(self.user_defined_device)
|
self.user_defined_device_button.clicked.connect(self.user_defined_device)
|
||||||
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
||||||
self.button_osx_symlinks.setVisible(isosx)
|
self.button_osx_symlinks.setVisible(isosx)
|
||||||
|
self.user_defined_device_button.setVisible(iswindows)
|
||||||
|
|
||||||
def debug_device_detection(self, *args):
|
def debug_device_detection(self, *args):
|
||||||
from calibre.gui2.preferences.device_debug import DebugDevice
|
from calibre.gui2.preferences.device_debug import DebugDevice
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="user_defined_device_button">
|
<widget class="QPushButton" name="user_defined_device_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Setup the &user defined device</string>
|
<string>Get information to setup the &user defined device (Windows only)</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user