This commit is contained in:
Kovid Goyal 2016-01-15 23:39:27 +05:30
parent 5dcd651998
commit 50586aa515

View File

@ -5,7 +5,7 @@
from __future__ import (unicode_literals, division, absolute_import, from __future__ import (unicode_literals, division, absolute_import,
print_function) print_function)
import os, string, _winreg as winreg, re, time import os, string, _winreg as winreg, re, time, errno
from contextlib import contextmanager from contextlib import contextmanager
from ctypes import ( from ctypes import (
Structure, POINTER, c_ubyte, windll, byref, c_void_p, WINFUNCTYPE, Structure, POINTER, c_ubyte, windll, byref, c_void_p, WINFUNCTYPE,
@ -13,7 +13,7 @@ from ctypes import (
wstring_at, addressof, create_unicode_buffer, string_at, c_uint64 as QWORD) wstring_at, addressof, create_unicode_buffer, string_at, c_uint64 as QWORD)
from ctypes.wintypes import DWORD, WORD, ULONG, LPCWSTR, HWND, BOOL, LPWSTR, UINT, BYTE, HANDLE from ctypes.wintypes import DWORD, WORD, ULONG, LPCWSTR, HWND, BOOL, LPWSTR, UINT, BYTE, HANDLE
from calibre.utils.winreg.lib import Key, HKEY_LOCAL_MACHINE, winerror from calibre.utils.winreg.lib import Key, HKEY_LOCAL_MACHINE
# Data and function type definitions {{{ # Data and function type definitions {{{
@ -482,7 +482,7 @@ def get_drive_letters_for_device(vendor_id, product_id, debug=False):
with Key(open_at='SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_%04X&PID_%04X' % (vid, pid), root=HKEY_LOCAL_MACHINE) as key: with Key(open_at='SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_%04X&PID_%04X' % (vid, pid), root=HKEY_LOCAL_MACHINE) as key:
available_uuids = {uuid.lower() for uuid in key.iterkeynames()} available_uuids = {uuid.lower() for uuid in key.iterkeynames()}
except WindowsError as err: except WindowsError as err:
if err.errno != winerror.ERROR_FILE_NOT_FOUND: if err.errno != errno.ENOENT:
raise raise
return ans return ans
if not available_uuids: if not available_uuids: