mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Device detection on OS X now directly queries the IOKit registry instead of parsing the output of the ioreg command. This means that the logic for detection on OS X is now very similar to linux.
This commit is contained in:
parent
0b3cf0b19f
commit
0a7dbe6099
@ -62,7 +62,7 @@ def migrate(old, new):
|
|||||||
|
|
||||||
def debug_device_driver():
|
def debug_device_driver():
|
||||||
from calibre.devices import debug
|
from calibre.devices import debug
|
||||||
print debug()
|
debug(ioreg_to_tmp=True, buf=sys.stdout)
|
||||||
if iswindows:
|
if iswindows:
|
||||||
raw_input('Press Enter to continue...')
|
raw_input('Press Enter to continue...')
|
||||||
|
|
||||||
|
@ -27,14 +27,15 @@ def strftime(epoch, zone=time.gmtime):
|
|||||||
src[2] = INVERSE_MONTH_MAP[int(src[2])]
|
src[2] = INVERSE_MONTH_MAP[int(src[2])]
|
||||||
return ' '.join(src)
|
return ' '.join(src)
|
||||||
|
|
||||||
def debug():
|
def debug(ioreg_to_tmp=False, buf=None):
|
||||||
from calibre.customize.ui import device_plugins
|
from calibre.customize.ui import device_plugins
|
||||||
from calibre.devices.scanner import DeviceScanner
|
from calibre.devices.scanner import DeviceScanner
|
||||||
from calibre.constants import iswindows, isosx, __version__
|
from calibre.constants import iswindows, isosx, __version__
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
oldo, olde = sys.stdout, sys.stderr
|
oldo, olde = sys.stdout, sys.stderr
|
||||||
|
|
||||||
buf = StringIO()
|
if buf is None:
|
||||||
|
buf = StringIO()
|
||||||
sys.stdout = sys.stderr = buf
|
sys.stdout = sys.stderr = buf
|
||||||
try:
|
try:
|
||||||
out = partial(prints, file=buf)
|
out = partial(prints, file=buf)
|
||||||
@ -82,16 +83,17 @@ def debug():
|
|||||||
connected_devices = []
|
connected_devices = []
|
||||||
for dev in device_plugins():
|
for dev in device_plugins():
|
||||||
out('Looking for', dev.__class__.__name__)
|
out('Looking for', dev.__class__.__name__)
|
||||||
connected = s.is_device_connected(dev, debug=True)
|
connected, det = s.is_device_connected(dev, debug=True)
|
||||||
if connected:
|
if connected:
|
||||||
connected_devices.append(dev)
|
connected_devices.append((dev, det))
|
||||||
|
|
||||||
errors = {}
|
errors = {}
|
||||||
success = False
|
success = False
|
||||||
for dev in connected_devices:
|
for dev, det in connected_devices:
|
||||||
out('Device possibly connected:', dev.__class__.name)
|
out('Device possibly connected:', dev.__class__.name)
|
||||||
out('Trying to open device...', end=' ')
|
out('Trying to open device...', end=' ')
|
||||||
try:
|
try:
|
||||||
|
dev.reset(detected_device=det)
|
||||||
dev.open()
|
dev.open()
|
||||||
out('OK')
|
out('OK')
|
||||||
except:
|
except:
|
||||||
@ -112,11 +114,17 @@ def debug():
|
|||||||
out(' ')
|
out(' ')
|
||||||
|
|
||||||
if ioreg is not None:
|
if ioreg is not None:
|
||||||
|
ioreg = 'IOREG Output\n'+ioreg
|
||||||
out(' ')
|
out(' ')
|
||||||
out('IOREG Output')
|
if ioreg_to_tmp:
|
||||||
out(ioreg)
|
open('/tmp/ioreg.txt', 'wb').write(ioreg)
|
||||||
|
out('Dont forget to send the contents of /tmp/ioreg.txt')
|
||||||
|
out('You can open it with the command: open /tmp/ioreg.txt')
|
||||||
|
else:
|
||||||
|
out(ioreg)
|
||||||
|
|
||||||
return buf.getvalue().decode('utf-8')
|
if hasattr(buf, 'getvalue'):
|
||||||
|
return buf.getvalue().decode('utf-8')
|
||||||
finally:
|
finally:
|
||||||
sys.stdout = oldo
|
sys.stdout = oldo
|
||||||
sys.stderr = olde
|
sys.stderr = olde
|
||||||
|
@ -460,9 +460,9 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
matches.sort(cmp=dcmp)
|
matches.sort(cmp=dcmp)
|
||||||
drives = {'main':matches[0]}
|
drives = {'main':matches[0]}
|
||||||
if len(matches > 1):
|
if len(matches) > 1:
|
||||||
drives['carda'] = matches[1]
|
drives['carda'] = matches[1]
|
||||||
if len(matches > 2):
|
if len(matches) > 2:
|
||||||
drives['cardb'] = matches[2]
|
drives['cardb'] = matches[2]
|
||||||
|
|
||||||
return drives
|
return drives
|
||||||
@ -476,11 +476,13 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
def open_osx(self):
|
def open_osx(self):
|
||||||
drives = self.osx_bsd_names()
|
drives = self.osx_bsd_names()
|
||||||
|
bsd_drives = dict(**drives)
|
||||||
drives = self.osx_sort_names(drives)
|
drives = self.osx_sort_names(drives)
|
||||||
mount_map = usbobserver.get_mounted_filesystems()
|
mount_map = usbobserver.get_mounted_filesystems()
|
||||||
for k, v in drives.items():
|
for k, v in drives.items():
|
||||||
drives[k] = mount_map.get(k, None)
|
drives[k] = mount_map.get(v, None)
|
||||||
if drives['main'] is None:
|
if drives['main'] is None:
|
||||||
|
print bsd_drives, mount_map, drives
|
||||||
raise DeviceError(_('Unable to detect the %s mount point. Try rebooting.')%self.__class__.__name__)
|
raise DeviceError(_('Unable to detect the %s mount point. Try rebooting.')%self.__class__.__name__)
|
||||||
self._main_prefix = drives['main']+os.sep
|
self._main_prefix = drives['main']+os.sep
|
||||||
def get_card_prefix(c):
|
def get_card_prefix(c):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user