mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Speed up device detection in windows and Fix #2287 (Calibre 0.5.7 No Longer Detects Kindle 2 When Plugged In)
This commit is contained in:
parent
8b34a4ebca
commit
cf77ec2c4a
@ -150,7 +150,7 @@ class PRS505(Device):
|
|||||||
time.sleep(6)
|
time.sleep(6)
|
||||||
drives = []
|
drives = []
|
||||||
wmi = __import__('wmi', globals(), locals(), [], -1)
|
wmi = __import__('wmi', globals(), locals(), [], -1)
|
||||||
c = wmi.WMI()
|
c = wmi.WMI(find_classes=False)
|
||||||
for drive in c.Win32_DiskDrive():
|
for drive in c.Win32_DiskDrive():
|
||||||
if self.__class__.is_device(str(drive.PNPDeviceID)):
|
if self.__class__.is_device(str(drive.PNPDeviceID)):
|
||||||
if drive.Partitions == 0:
|
if drive.Partitions == 0:
|
||||||
|
@ -186,7 +186,7 @@ class Device(_Device):
|
|||||||
time.sleep(6)
|
time.sleep(6)
|
||||||
drives = {}
|
drives = {}
|
||||||
wmi = __import__('wmi', globals(), locals(), [], -1)
|
wmi = __import__('wmi', globals(), locals(), [], -1)
|
||||||
c = wmi.WMI()
|
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_MAIN_MEM):
|
if self.windows_match_device(str(drive.PNPDeviceID), self.WINDOWS_MAIN_MEM):
|
||||||
drives['main'] = self.windows_get_drive_prefix(drive)
|
drives['main'] = self.windows_get_drive_prefix(drive)
|
||||||
|
@ -11,6 +11,7 @@ from PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, QPixmap, \
|
|||||||
Qt
|
Qt
|
||||||
|
|
||||||
from calibre.devices import devices
|
from calibre.devices import devices
|
||||||
|
from calibre.constants import iswindows
|
||||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||||
from calibre.parallel import Job
|
from calibre.parallel import Job
|
||||||
from calibre.devices.scanner import DeviceScanner
|
from calibre.devices.scanner import DeviceScanner
|
||||||
@ -69,7 +70,14 @@ class DeviceManager(Thread):
|
|||||||
if connected and not device[1]:
|
if connected and not device[1]:
|
||||||
try:
|
try:
|
||||||
dev = device[0]()
|
dev = device[0]()
|
||||||
|
if iswindows:
|
||||||
|
import pythoncom
|
||||||
|
pythoncom.CoInitialize()
|
||||||
|
try:
|
||||||
dev.open()
|
dev.open()
|
||||||
|
finally:
|
||||||
|
if iswindows:
|
||||||
|
pythoncom.CoUninitialize()
|
||||||
self.device = dev
|
self.device = dev
|
||||||
self.device_class = dev.__class__
|
self.device_class = dev.__class__
|
||||||
self.connected_slot(True)
|
self.connected_slot(True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user