mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-06 11:44:49 +01: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
3 changed files with 11 additions and 3 deletions
|
|
@ -150,7 +150,7 @@ def open_windows(self):
|
|||
time.sleep(6)
|
||||
drives = []
|
||||
wmi = __import__('wmi', globals(), locals(), [], -1)
|
||||
c = wmi.WMI()
|
||||
c = wmi.WMI(find_classes=False)
|
||||
for drive in c.Win32_DiskDrive():
|
||||
if self.__class__.is_device(str(drive.PNPDeviceID)):
|
||||
if drive.Partitions == 0:
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ def open_windows(self):
|
|||
time.sleep(6)
|
||||
drives = {}
|
||||
wmi = __import__('wmi', globals(), locals(), [], -1)
|
||||
c = wmi.WMI()
|
||||
c = wmi.WMI(find_classes=False)
|
||||
for drive in c.Win32_DiskDrive():
|
||||
if self.windows_match_device(str(drive.PNPDeviceID), self.WINDOWS_MAIN_MEM):
|
||||
drives['main'] = self.windows_get_drive_prefix(drive)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
Qt
|
||||
|
||||
from calibre.devices import devices
|
||||
from calibre.constants import iswindows
|
||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||
from calibre.parallel import Job
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
|
|
@ -69,7 +70,14 @@ def detect_device(self):
|
|||
if connected and not device[1]:
|
||||
try:
|
||||
dev = device[0]()
|
||||
dev.open()
|
||||
if iswindows:
|
||||
import pythoncom
|
||||
pythoncom.CoInitialize()
|
||||
try:
|
||||
dev.open()
|
||||
finally:
|
||||
if iswindows:
|
||||
pythoncom.CoUninitialize()
|
||||
self.device = dev
|
||||
self.device_class = dev.__class__
|
||||
self.connected_slot(True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue