mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Pull from trunk
This commit is contained in:
commit
50c163d25d
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
__appname__ = 'calibre'
|
||||
__version__ = '0.5.9'
|
||||
__version__ = '0.5.10'
|
||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||
'''
|
||||
Various run time constants.
|
||||
|
@ -117,6 +117,7 @@ def debug_device_driver():
|
||||
print 'Trying to open device...'
|
||||
d = dev()
|
||||
d.open()
|
||||
print 'Main memory:', repr(d._main_prefix)
|
||||
print 'Total space:', d.total_space()
|
||||
break
|
||||
|
||||
|
@ -2,6 +2,13 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
'''
|
||||
Device driver for the Netronix EB600
|
||||
|
||||
Windows PNP strings:
|
||||
('USBSTOR\\DISK&VEN_NETRONIX&PROD_EBOOK&REV_062E\\6&1A275569&0&EB6001009
|
||||
2W00000&0', 2, u'F:\\')
|
||||
('USBSTOR\\DISK&VEN_NETRONIX&PROD_EBOOK&REV_062E\\6&1A275569&0&EB6001009
|
||||
2W00000&1', 3, u'G:\\')
|
||||
|
||||
'''
|
||||
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
@ -35,8 +42,8 @@ class EB600(USBMS):
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
def windows_sort_drives(self, drives):
|
||||
main = drives['main']
|
||||
card = drives['carda']
|
||||
main = drives.get('main', None)
|
||||
card = drives.get('card', None)
|
||||
if card and main and card < main:
|
||||
drives['main'] = card
|
||||
drives['carda'] = main
|
||||
|
@ -29,9 +29,6 @@ class JETBOOK(USBMS):
|
||||
WINDOWS_MAIN_MEM = 'EBOOK'
|
||||
WINDOWS_CARD_MEM = 'EBOOK'
|
||||
|
||||
WINDOWS_MAIN_MEM = None
|
||||
WINDOWS_CARD_MEM = None
|
||||
|
||||
OSX_MAIN_MEM = None
|
||||
OSX_CARD_MEM = None
|
||||
|
||||
@ -116,8 +113,8 @@ class JETBOOK(USBMS):
|
||||
return mi
|
||||
|
||||
def windows_sort_drives(self, drives):
|
||||
main = drives['main']
|
||||
card = drives['card']
|
||||
main = drives.get('main', None)
|
||||
card = drives.get('card', None)
|
||||
if card and main and card < main:
|
||||
drives['main'] = card
|
||||
drives['card'] = main
|
||||
|
@ -8,11 +8,11 @@ device. This class handles device detection.
|
||||
|
||||
import os, subprocess, time, re
|
||||
|
||||
from calibre.devices.interface import DevicePlugin as Device
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.devices.errors import DeviceError
|
||||
from calibre import iswindows, islinux, isosx, __appname__
|
||||
|
||||
class Device(Device):
|
||||
class Device(DevicePlugin):
|
||||
'''
|
||||
This class provides logic common to all drivers for devices that export themselves
|
||||
as USB Mass Storage devices. If you are writing such a driver, inherit from this
|
||||
@ -122,7 +122,7 @@ class Device(Device):
|
||||
|
||||
@classmethod
|
||||
def _windows_space(cls, prefix):
|
||||
if prefix is None:
|
||||
if not prefix:
|
||||
return 0, 0
|
||||
win32file = __import__('win32file', globals(), locals(), [], -1)
|
||||
try:
|
||||
@ -221,16 +221,16 @@ class Device(Device):
|
||||
if 'main' in drives.keys() and 'carda' in drives.keys() and 'cardb' in drives.keys():
|
||||
break
|
||||
|
||||
drives = self.windows_sort_drives(drives)
|
||||
self._main_prefix = drives.get('main')
|
||||
self._card_a_prefix = drives.get('carda')
|
||||
self._card_b_prefix = drives.get('cardb')
|
||||
|
||||
if not self._main_prefix:
|
||||
if 'main' not in drives:
|
||||
raise DeviceError(
|
||||
_('Unable to detect the %s disk drive. Try rebooting.') %
|
||||
self.__class__.__name__)
|
||||
|
||||
drives = self.windows_sort_drives(drives)
|
||||
self._main_prefix = drives.get('main')
|
||||
self._card_a_prefix = drives.get('carda', None)
|
||||
self._card_b_prefix = drives.get('cardb', None)
|
||||
|
||||
def get_osx_mountpoints(self, raw=None):
|
||||
if raw is None:
|
||||
ioreg = '/usr/sbin/ioreg'
|
||||
@ -272,16 +272,16 @@ class Device(Device):
|
||||
self._main_prefix = re.search(main_pat, mount).group(2) + os.sep
|
||||
card_a_pat = names['carda'] if 'carda' in names.keys() else None
|
||||
card_b_pat = names['cardb'] if 'cardb' in names.keys() else None
|
||||
|
||||
|
||||
def get_card_prefix(pat):
|
||||
if pat is not None:
|
||||
pat = dev_pat % pat
|
||||
return re.search(pat, mount).group(2) + os.sep
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
self._card_a_prefix = get_card_prefix(card_a_pat)
|
||||
self._card_b_prefix = get_card_prefix(card_b_pat)
|
||||
self._card_b_prefix = get_card_prefix(card_b_pat)
|
||||
|
||||
def open_linux(self):
|
||||
import dbus
|
||||
|
@ -38,10 +38,6 @@ class USBMS(CLI, Device):
|
||||
report_progress=report_progress)
|
||||
|
||||
def get_device_information(self, end_session=True):
|
||||
"""
|
||||
Ask device for device information. See L{DeviceInfoQuery}.
|
||||
@return: (device name, device version, software version on device, mime type)
|
||||
"""
|
||||
return (self.__class__.__name__, '', '', '')
|
||||
|
||||
def books(self, oncard=None, end_session=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user