mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Device drivers: Always print out device ids in debug mode. Also get manufacturer, product ans serial number strings on OS X
This commit is contained in:
parent
d926d7d4c5
commit
01da2517fc
@ -55,7 +55,6 @@ class CYBOOKG3(USBMS):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_handle(cls, device_info, debug=False):
|
def can_handle(cls, device_info, debug=False):
|
||||||
USBMS.can_handle(device_info, debug)
|
|
||||||
if islinux:
|
if islinux:
|
||||||
return device_info[3] == 'Bookeen' and device_info[4] == 'Cybook Gen3'
|
return device_info[3] == 'Bookeen' and device_info[4] == 'Cybook Gen3'
|
||||||
return True
|
return True
|
||||||
@ -88,7 +87,6 @@ class CYBOOK_OPUS(CYBOOKG3):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_handle(cls, device_info, debug=False):
|
def can_handle(cls, device_info, debug=False):
|
||||||
USBMS.can_handle(device_info, debug)
|
|
||||||
if islinux:
|
if islinux:
|
||||||
return device_info[3] == 'Bookeen'
|
return device_info[3] == 'Bookeen'
|
||||||
return True
|
return True
|
||||||
|
@ -55,7 +55,15 @@ class DevicePlugin(Plugin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_usb_connected_windows(cls, devices_on_system):
|
def print_usb_device_info(cls, info):
|
||||||
|
try:
|
||||||
|
print '\t', repr(info)
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_usb_connected_windows(cls, devices_on_system, debug=False):
|
||||||
|
|
||||||
def id_iterator():
|
def id_iterator():
|
||||||
if hasattr(cls.VENDOR_ID, 'keys'):
|
if hasattr(cls.VENDOR_ID, 'keys'):
|
||||||
@ -75,9 +83,13 @@ class DevicePlugin(Plugin):
|
|||||||
vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id
|
vid, pid = 'vid_%4.4x'%vendor_id, 'pid_%4.4x'%product_id
|
||||||
vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id
|
vidd, pidd = 'vid_%i'%vendor_id, 'pid_%i'%product_id
|
||||||
for device_id in devices_on_system:
|
for device_id in devices_on_system:
|
||||||
if (vid in device_id or vidd in device_id) and (pid in device_id or pidd in device_id):
|
if (vid in device_id or vidd in device_id) and \
|
||||||
if cls.test_bcd_windows(device_id, bcd) and cls.can_handle(device_id):
|
(pid in device_id or pidd in device_id) and \
|
||||||
return True
|
cls.test_bcd_windows(device_id, bcd):
|
||||||
|
if debug:
|
||||||
|
cls.print_usb_device_info(device_id)
|
||||||
|
if cls.can_handle(device_id):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -97,7 +109,7 @@ class DevicePlugin(Plugin):
|
|||||||
:param devices_on_system: List of devices currently connected
|
:param devices_on_system: List of devices currently connected
|
||||||
'''
|
'''
|
||||||
if iswindows:
|
if iswindows:
|
||||||
return cls.is_usb_connected_windows(devices_on_system)
|
return cls.is_usb_connected_windows(devices_on_system, debug=debug)
|
||||||
|
|
||||||
vendors_on_system = set([x[0] for x in devices_on_system])
|
vendors_on_system = set([x[0] for x in devices_on_system])
|
||||||
vendors = cls.VENDOR_ID if hasattr(cls.VENDOR_ID, '__len__') else [cls.VENDOR_ID]
|
vendors = cls.VENDOR_ID if hasattr(cls.VENDOR_ID, '__len__') else [cls.VENDOR_ID]
|
||||||
@ -118,9 +130,11 @@ class DevicePlugin(Plugin):
|
|||||||
cbcd = cls.VENDOR_ID[vid][pid]
|
cbcd = cls.VENDOR_ID[vid][pid]
|
||||||
else:
|
else:
|
||||||
cbcd = cls.BCD
|
cbcd = cls.BCD
|
||||||
if cls.test_bcd(bcd, cbcd) and cls.can_handle(dev,
|
if cls.test_bcd(bcd, cbcd):
|
||||||
debug=debug):
|
if debug:
|
||||||
return True
|
cls.print_usb_device_info(dev)
|
||||||
|
if cls.can_handle(dev, debug=debug):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@ -152,12 +166,6 @@ class DevicePlugin(Plugin):
|
|||||||
:param device_info: On windows a device ID string. On Unix a tuple of
|
:param device_info: On windows a device ID string. On Unix a tuple of
|
||||||
``(vendor_id, product_id, bcd)``.
|
``(vendor_id, product_id, bcd)``.
|
||||||
'''
|
'''
|
||||||
try:
|
|
||||||
if debug:
|
|
||||||
print '\t', repr(device_info)
|
|
||||||
except:
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
|
@ -40,6 +40,7 @@ class LinuxScanner(object):
|
|||||||
prod = os.path.join(base, 'idProduct')
|
prod = os.path.join(base, 'idProduct')
|
||||||
bcd = os.path.join(base, 'bcdDevice')
|
bcd = os.path.join(base, 'bcdDevice')
|
||||||
man = os.path.join(base, 'manufacturer')
|
man = os.path.join(base, 'manufacturer')
|
||||||
|
serial = os.path.join(base, 'serial')
|
||||||
prod_string = os.path.join(base, 'product')
|
prod_string = os.path.join(base, 'product')
|
||||||
dev = []
|
dev = []
|
||||||
try:
|
try:
|
||||||
@ -62,6 +63,11 @@ class LinuxScanner(object):
|
|||||||
dev.append(open(prod_string).read().strip())
|
dev.append(open(prod_string).read().strip())
|
||||||
except:
|
except:
|
||||||
dev.append('')
|
dev.append('')
|
||||||
|
try:
|
||||||
|
dev.append(open(serial).read().strip())
|
||||||
|
except:
|
||||||
|
dev.append('')
|
||||||
|
|
||||||
ans.add(tuple(dev))
|
ans.add(tuple(dev))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ usbobserver_get_usb_devices(PyObject *self, PyObject *args) {
|
|||||||
serial = get_iokit_string_property(usbDevice, 2);
|
serial = get_iokit_string_property(usbDevice, 2);
|
||||||
if (serial == NULL) serial = Py_None;
|
if (serial == NULL) serial = Py_None;
|
||||||
|
|
||||||
device = Py_BuildValue("(iiiOOO)", vendor, product, bcd, manufacturer, productn, serial);
|
device = Py_BuildValue("(iiiNNN)", vendor, product, bcd, manufacturer, productn, serial);
|
||||||
if (device == NULL) {
|
if (device == NULL) {
|
||||||
IOObjectRelease(usbDevice);
|
IOObjectRelease(usbDevice);
|
||||||
(*plugInInterface)->Release(plugInInterface);
|
(*plugInInterface)->Release(plugInInterface);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user