Fix #4152 (Error launching calibre when Droid is mounted)

This commit is contained in:
Kovid Goyal 2009-12-10 10:18:43 -07:00
parent 6914dd8b20
commit 5ce0d7aba8
3 changed files with 12 additions and 5 deletions

View File

@ -36,12 +36,12 @@ class ANDROID(USBMS):
SUPPORTS_SUB_DIRS = True SUPPORTS_SUB_DIRS = True
def get_main_ebook_dir(self): def post_open_callback(self):
opts = self.settings() opts = self.settings()
dirs = opts.extra_customization dirs = opts.extra_customization
if not dirs: if not dirs:
dirs = self.EBOOK_DIR_MAIN dirs = self.EBOOK_DIR_MAIN
else: else:
dirs = [x.strip() for x in dirs.split(',')] dirs = [x.strip() for x in dirs.split(',')]
return dirs self.EBOOK_DIR_MAIN = dirs

View File

@ -578,7 +578,7 @@ class Device(DeviceConfig, DevicePlugin):
try: try:
self.open_windows() self.open_windows()
except DeviceError: except DeviceError:
time.sleep(5) time.sleep(7)
self.open_windows() self.open_windows()
if isosx: if isosx:
try: try:
@ -587,6 +587,11 @@ class Device(DeviceConfig, DevicePlugin):
time.sleep(7) time.sleep(7)
self.open_osx() self.open_osx()
self.post_open_callback()
def post_open_callback(self):
pass
def eject_windows(self): def eject_windows(self):
from calibre.constants import plugins from calibre.constants import plugins
from threading import Thread from threading import Thread

View File

@ -21,7 +21,7 @@ from calibre.devices.usbms.device import Device
from calibre.devices.usbms.books import BookList, Book from calibre.devices.usbms.books import BookList, Book
from calibre.devices.mime import mime_type_ext from calibre.devices.mime import mime_type_ext
# CLI must come before Device as it implments the CLI functions that # CLI must come before Device as it implements the CLI functions that
# are inherited from the device interface in Device. # are inherited from the device interface in Device.
class USBMS(CLI, Device): class USBMS(CLI, Device):
@ -56,7 +56,9 @@ class USBMS(CLI, Device):
return bl return bl
prefix = self._card_a_prefix if oncard == 'carda' else self._card_b_prefix if oncard == 'cardb' else self._main_prefix prefix = self._card_a_prefix if oncard == 'carda' else self._card_b_prefix if oncard == 'cardb' else self._main_prefix
ebook_dir = self.EBOOK_DIR_CARD_A if oncard == 'carda' else self.EBOOK_DIR_CARD_B if oncard == 'cardb' else self.EBOOK_DIR_MAIN ebook_dir = self.EBOOK_DIR_CARD_A if oncard == 'carda' else \
self.EBOOK_DIR_CARD_B if oncard == 'cardb' else \
self.get_main_ebook_dir()
# Get all books in the ebook_dir directory # Get all books in the ebook_dir directory
if self.SUPPORTS_SUB_DIRS: if self.SUPPORTS_SUB_DIRS: