Fix BeBook device detection.

This commit is contained in:
John Schember 2009-06-14 15:08:38 -04:00
parent 940734ab36
commit 0c3e217e41
2 changed files with 25 additions and 3 deletions

View File

@ -1,9 +1,12 @@
__license__ = 'GPL v3'
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
'''
Device driver for BeBook
'''
import re
from calibre.devices.usbms.driver import USBMS
class BEBOOK(USBMS):
@ -24,8 +27,8 @@ class BEBOOK(USBMS):
WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET'
WINDOWS_CARD_A_MEM = 'FILE-STOR_GADGET'
OSX_MAIN_MEM = 'BeBook Internal Memory'
OSX_CARD_A_MEM = 'BeBook Storage Card'
OSX_MAIN_MEM = 'Linux File-Stor Gadget Media'
OSX_CARD_A_MEM = 'Linux File-Stor Gadget Media'
MAIN_MEMORY_VOLUME_LABEL = 'BeBook Internal Memory'
STORAGE_CARD_VOLUME_LABEL = 'BeBook Storage Card'
@ -43,6 +46,23 @@ class BEBOOK(USBMS):
return drives
def osx_sort_names(self, names):
main = names.get('main', None)
card = names.get('carda', None)
main_num = int(re.findall('\d+', main)[0]) if main else None
card_num = int(re.findall('\d+', card)[0]) if card else None
if card_num is not None and main_num is not None and card_num < main_num:
names['main'] = card
names['carda'] = main
if card and not main:
names['main'] = card
names['carda'] = None
return names
def linux_swap_drives(self, drives):
if len(drives) < 2: return drives
drives = list(drives)

View File

@ -265,6 +265,8 @@ class Device(DeviceConfig, DevicePlugin):
return subprocess.Popen((ioreg+' -w 0 -S -c IOMedia').split(),
stdout=subprocess.PIPE).communicate()[0]
def osx_sort_names(self, names):
return names
def get_osx_mountpoints(self, raw=None):
raw = self.run_ioreg(raw)
@ -290,7 +292,7 @@ class Device(DeviceConfig, DevicePlugin):
get_dev_node(lines[i+1:], 'cardb')
if len(names.keys()) == 3:
break
return names
return self.osx_sort_names(names)
def open_osx(self):
mount = subprocess.Popen('mount', shell=True, stdout=subprocess.PIPE).stdout.read()