From 3cfe6d95a219a4fd6579a8362716c2c7062fb551 Mon Sep 17 00:00:00 2001 From: Li Fanxi Date: Thu, 16 Dec 2010 00:14:41 +0800 Subject: [PATCH] [Device] Give prompts when Bambook SDK is not avalible. --- src/calibre/devices/bambook/driver.py | 6 +++++- src/calibre/devices/bambook/libbambookcore.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/bambook/driver.py b/src/calibre/devices/bambook/driver.py index a687d3b88d..b1731306ca 100644 --- a/src/calibre/devices/bambook/driver.py +++ b/src/calibre/devices/bambook/driver.py @@ -12,11 +12,12 @@ import time, os, hashlib from itertools import cycle from calibre.devices.interface import DevicePlugin from calibre.devices.usbms.deviceconfig import DeviceConfig -from calibre.devices.bambook.libbambookcore import Bambook, text_encoding, CONN_CONNECTED +from calibre.devices.bambook.libbambookcore import Bambook, text_encoding, CONN_CONNECTED, is_bambook_lib_ready from calibre.devices.usbms.books import Book, BookList from calibre.ebooks.metadata.book.json_codec import JsonCodec from calibre.ptempfile import TemporaryDirectory, TemporaryFile from calibre.constants import __appname__, __version__ +from calibre.devices.errors import OpenFeedback class BAMBOOK(DeviceConfig, DevicePlugin): name = 'Bambook Device Interface' @@ -52,6 +53,9 @@ class BAMBOOK(DeviceConfig, DevicePlugin): self.open() def open(self): + # Make sure the Bambook library is ready + if not is_bambook_lib_ready(): + raise OpenFeedback(_("Unable to connect to Bambook, you need to install Bambook library first.")) # Disconnect first if connected self.eject() # Connect diff --git a/src/calibre/devices/bambook/libbambookcore.py b/src/calibre/devices/bambook/libbambookcore.py index 9bae22b83f..12a88d5f62 100644 --- a/src/calibre/devices/bambook/libbambookcore.py +++ b/src/calibre/devices/bambook/libbambookcore.py @@ -38,6 +38,9 @@ elif islinux: elif isosx: text_encoding = 'utf-8' +def is_bambook_lib_ready(): + return lib_handle != None + # Constant DEFAULT_BAMBOOK_IP = '192.168.250.2' BAMBOOK_SDK_VERSION = 0x00090000