mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 03:04:42 +02:00
Driver for the Ectaco JetBook by James Ralston
This commit is contained in:
parent
02be6743ad
commit
5790166c63
5 changed files with 95 additions and 5 deletions
|
|
@ -14,8 +14,9 @@ def devices():
|
|||
from calibre.devices.kindle.driver import KINDLE2
|
||||
from calibre.devices.blackberry.driver import BLACKBERRY
|
||||
from calibre.devices.eb600.driver import EB600
|
||||
from calibre.devices.jetbook.driver import JETBOOK
|
||||
return (PRS500, PRS505, PRS700, CYBOOKG3, KINDLE, KINDLE2,
|
||||
BLACKBERRY, EB600)
|
||||
BLACKBERRY, EB600, JETBOOK)
|
||||
|
||||
import time
|
||||
|
||||
|
|
|
|||
0
src/calibre/devices/jetbook/__init__.py
Normal file
0
src/calibre/devices/jetbook/__init__.py
Normal file
84
src/calibre/devices/jetbook/driver.py
Normal file
84
src/calibre/devices/jetbook/driver.py
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
|
||||
'''
|
||||
Device driver for Ectaco Jetbook firmware >= JL04_v030e
|
||||
'''
|
||||
|
||||
import os, shutil
|
||||
from itertools import cycle
|
||||
|
||||
from calibre.devices.errors import FreeSpaceError
|
||||
from calibre.devices.usbms.driver import USBMS
|
||||
from calibre.devices.usbms.books import BookList
|
||||
from calibre import sanitize_file_name as sanitize
|
||||
|
||||
class JETBOOK(USBMS):
|
||||
# Ordered list of supported formats
|
||||
# Be sure these have an entry in calibre.devices.mime
|
||||
FORMATS = [ 'epub', 'mobi', 'prc', 'txt', 'rtf', 'pdf']
|
||||
|
||||
VENDOR_ID = [0x0525]
|
||||
PRODUCT_ID = [0xa4a5]
|
||||
BCD = [0x314]
|
||||
|
||||
VENDOR_NAME = 'NETCHIP'
|
||||
|
||||
WINDOWS_MAIN_MEM = None
|
||||
WINDOWS_CARD_MEM = None
|
||||
|
||||
OSX_MAIN_MEM = None
|
||||
OSX_CARD_MEM = None
|
||||
|
||||
MAIN_MEMORY_VOLUME_LABEL = 'Jetbook Main Memory'
|
||||
STORAGE_CARD_VOLUME_LABEL = 'Jetbook Storage Card'
|
||||
|
||||
EBOOK_DIR_MAIN = "Books"
|
||||
EBOOK_DIR_CARD = "Books"
|
||||
SUPPORTS_SUB_DIRS = True
|
||||
|
||||
def upload_books(self, files, names, on_card=False, end_session=True,
|
||||
metadata=None):
|
||||
|
||||
path = self._sanity_check(on_card, files)
|
||||
|
||||
paths = []
|
||||
names = iter(names)
|
||||
metadata = iter(metadata)
|
||||
|
||||
for infile in files:
|
||||
newpath = path
|
||||
|
||||
if self.SUPPORTS_SUB_DIRS:
|
||||
mdata = metadata.next()
|
||||
|
||||
if 'tags' in mdata.keys():
|
||||
for tag in mdata['tags']:
|
||||
if tag.startswith('/'):
|
||||
newpath += tag
|
||||
newpath = os.path.normpath(newpath)
|
||||
break
|
||||
|
||||
if not os.path.exists(newpath):
|
||||
os.makedirs(newpath)
|
||||
|
||||
author = sanitize(mdata.get('authors','Unknown'))
|
||||
title = sanitize(mdata.get('title', 'Unknown'))
|
||||
(basename, fileext) = os.path.splitext(os.path.basename(names.next()))
|
||||
fname = '%s#%s%s' % (author, title, fileext)
|
||||
|
||||
filepath = os.path.join(newpath, fname)
|
||||
paths.append(filepath)
|
||||
|
||||
if hasattr(infile, 'read'):
|
||||
infile.seek(0)
|
||||
|
||||
dest = open(filepath, 'wb')
|
||||
shutil.copyfileobj(infile, dest, 10*1024*1024)
|
||||
|
||||
dest.flush()
|
||||
dest.close()
|
||||
else:
|
||||
shutil.copy2(infile, filepath)
|
||||
|
||||
return zip(paths, cycle([on_card]))
|
||||
|
||||
|
|
@ -71,8 +71,7 @@ def books(self, oncard=False, end_session=True):
|
|||
bl.append(self.__class__.book_from_path(os.path.join(path, filename)))
|
||||
return bl
|
||||
|
||||
def upload_books(self, files, names, on_card=False, end_session=True,
|
||||
metadata=None):
|
||||
def _sanity_check(self, on_card, files):
|
||||
if on_card and not self._card_prefix:
|
||||
raise ValueError(_('The reader has no storage card connected.'))
|
||||
|
||||
|
|
@ -96,6 +95,12 @@ def get_size(obj):
|
|||
raise FreeSpaceError(_("There is insufficient free space on the storage card"))
|
||||
if not on_card and size > self.free_space()[0] - 2*1024*1024:
|
||||
raise FreeSpaceError(_("There is insufficient free space in main memory"))
|
||||
return path
|
||||
|
||||
def upload_books(self, files, names, on_card=False, end_session=True,
|
||||
metadata=None):
|
||||
|
||||
path = self._sanity_check(on_card, files)
|
||||
|
||||
paths = []
|
||||
names = iter(names)
|
||||
|
|
|
|||
|
|
@ -1571,8 +1571,8 @@ def main(args=sys.argv):
|
|||
extra = '' if iswindows else \
|
||||
('If you\'re sure it is not running, delete the file '
|
||||
'%s.'%os.path.expanduser('~/.calibre_calibre GUI.lock'))
|
||||
QMessageBox.critical(None, 'Cannot Start '+__appname__,
|
||||
'<p>%s is already running. %s</p>'%(__appname__, extra))
|
||||
QMessageBox.critical(None, _('Cannot Start ')+__appname__,
|
||||
_('<p>%s is already running. %s</p>')%(__appname__, extra))
|
||||
return 1
|
||||
initialize_file_icon_provider()
|
||||
main = Main(single_instance, opts, actions)
|
||||
|
|
|
|||
Loading…
Reference in a new issue