OS X support

This commit is contained in:
John Schember 2009-01-07 20:40:09 -05:00
parent 426cde07dd
commit adaa9484f3
3 changed files with 60 additions and 4 deletions

View File

@ -27,6 +27,9 @@ class CYBOOKG3(USBMS):
VENDOR_NAME = 'BOOKEEN' VENDOR_NAME = 'BOOKEEN'
PRODUCT_NAME = 'CYBOOK_GEN3' PRODUCT_NAME = 'CYBOOK_GEN3'
OSX_NAME_MAIN_MEM = 'Bookeen Cybook Gen3 -FD Media'
OSX_NAME_CARD_MEM = 'Bookeen Cybook Gen3 -SD Media'
MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory' MAIN_MEMORY_VOLUME_LABEL = 'Cybook Gen 3 Main Memory'
STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card' STORAGE_CARD_VOLUME_LABEL = 'Cybook Gen 3 Storage Card'

View File

@ -19,6 +19,19 @@ class Device(_Device):
class. class.
''' '''
VENDOR_ID = 0x0
PRODUCT_ID = 0x0
BCD = 0x0
VENDOR_NAME = ''
PRODUCT_NAME = ''
OSX_NAME_MAIN_MEM = ''
OSX_NAME_CARD_MEM = ''
MAIN_MEMORY_VOLUME_LABEL = ''
STORAGE_CARD_VOLUME_LABEL = ''
FDI_TEMPLATE = \ FDI_TEMPLATE = \
''' '''
<device> <device>
@ -158,8 +171,47 @@ class Device(_Device):
if len(drives) > 1: if len(drives) > 1:
self._card_prefix = drives[1][1] self._card_prefix = drives[1][1]
@classmethod
def get_osx_mountpoints(cls, raw=None):
if raw is None:
ioreg = '/usr/sbin/ioreg'
if not os.access(ioreg, os.X_OK):
ioreg = 'ioreg'
raw = subprocess.Popen((ioreg+' -w 0 -S -c IOMedia').split(), stdout=subprocess.PIPE).stdout.read()
lines = raw.splitlines()
names = {}
def get_dev_node(lines, loc):
for line in lines:
line = line.strip()
if line.endswith('}'):
break
match = re.search(r'"BSD Name"\s+=\s+"(.*?)"', line)
if match is not None:
names[loc] = match.group(1)
break
for i, line in enumerate(lines):
if line.strip().endswith('<class IOMedia>') and OSX_NAME_MAIN_MEM in line:
get_dev_node(lines[i+1:], 'main')
if line.strip().endswith('<class IOMedia>') and OSX_NAME_CARD_MEM in line:
get_dev_node(lines[i+1:], 'card')
if len(names.keys()) == 2:
break
return names
def open_osx(self): def open_osx(self):
raise NotImplementedError() mount = subprocess.Popen('mount', shell=True, stdout=subprocess.PIPE).stdout.read()
names = self.get_osx_mountpoints()
dev_pat = r'/dev/%s(\w*)\s+on\s+([^\(]+)\s+'
if 'main' not in names.keys():
raise DeviceError(_('Unable to detect the %s disk drive. Try rebooting.')%self.__class__.__name__)
main_pat = dev_pat%names['main']
self._main_prefix = re.search(main_pat, mount).group(2) + os.sep
card_pat = names['card'] if 'card' in names.keys() else None
if card_pat is not None:
card_pat = dev_pat%card_pat
self._card_prefix = re.search(card_pat, mount).group(2) + os.sep
def open_linux(self): def open_linux(self):
import dbus import dbus

View File

@ -16,6 +16,7 @@ from calibre.devices.errors import FreeSpaceError
class USBMS(Device): class USBMS(Device):
EBOOK_DIR = '' EBOOK_DIR = ''
MIME_MAP = {} MIME_MAP = {}
FORMATS = []
def __init__(self, key='-1', log_packets=False, report_progress=None): def __init__(self, key='-1', log_packets=False, report_progress=None):
pass pass