diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index e8f6870016..25ad089afa 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -354,8 +354,8 @@ from calibre.customize.profiles import input_profiles, output_profiles from calibre.devices.bebook.driver import BEBOOK, BEBOOK_MINI from calibre.devices.blackberry.driver import BLACKBERRY -from calibre.devices.cybookg3.driver import CYBOOKG3 -from calibre.devices.eb600.driver import EB600 +from calibre.devices.cybookg3.driver import CYBOOKG3, CYBOOK_OPUS +from calibre.devices.eb600.driver import EB600, COOL_ER from calibre.devices.iliad.driver import ILIAD from calibre.devices.irexdr.driver import IREXDR1000 from calibre.devices.jetbook.driver import JETBOOK @@ -412,6 +412,8 @@ plugins += [ PRS505, PRS700, ANDROID, + CYBOOK_OPUS, + COOL_ER ] plugins += [x for x in list(locals().values()) if isinstance(x, type) and \ x.__name__.endswith('MetadataReader')] diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 62582288e7..0b09442eac 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -114,16 +114,37 @@ def debug_device_driver(): raw = Device.run_ioreg() open('/tmp/ioreg.txt', 'wb').write(raw) print 'ioreg output saved to /tmp/ioreg.txt' + connected_devices = [] for dev in device_plugins(): print 'Looking for', dev.__class__.__name__ connected = s.is_device_connected(dev) if connected: - print 'Device Connected:', dev - print 'Trying to open device...' + connected_devices.append(dev) + + errors = {} + success = False + for dev in connected_devices: + print 'Device possibly connected:', dev + print 'Trying to open device...', + try: dev.open() - print 'Main memory:', repr(dev._main_prefix) - print 'Total space:', dev.total_space() - break + print 'OK' + except: + import traceback + errors[dev] = traceback.format_exc() + print 'failed' + continue + success = True + print 'Main memory:', repr(dev._main_prefix) + print 'Total space:', dev.total_space() + break + if not success and errors: + print 'Opening of the following devices failed' + for dev,msg in errors.items(): + print dev + print msg + print + def add_simple_plugin(path_to_plugin): import tempfile, zipfile, shutil diff --git a/src/calibre/devices/cybookg3/driver.py b/src/calibre/devices/cybookg3/driver.py index d3ccf85461..8c64637f57 100644 --- a/src/calibre/devices/cybookg3/driver.py +++ b/src/calibre/devices/cybookg3/driver.py @@ -124,3 +124,23 @@ class CYBOOKG3(USBMS): except: pass self.report_progress(1.0, _('Removing books from device...')) + +class CYBOOK_OPUS(CYBOOKG3): + + FORMATS = ['epub', 'pdf', 'txt'] + + VENDOR_ID = [0x0bda] + PRODUCT_ID = [0x0703] + BCD = [0x110] + + WINDOWS_MAIN_MEM = 'CYBOOK_OPUS__-FD' + WINDOWS_CARD_A_MEM = 'CYBOOK_OPUS__-SD' + + OSX_MAIN_MEM = 'Bookeen Cybook Opus -FD Media' + OSX_CARD_A_MEM = 'Bookeen Cybook Opus -SD Media' + + def upload_books(self, *args, **kwargs): + USBMS.upload_books(self, *args, **kwargs) + + def delete_books(self, *args, **kwargs): + USBMS.delete_books(self, *args, **kwargs) diff --git a/src/calibre/devices/eb600/driver.py b/src/calibre/devices/eb600/driver.py index b42c77f172..70f527f79e 100644 --- a/src/calibre/devices/eb600/driver.py +++ b/src/calibre/devices/eb600/driver.py @@ -20,7 +20,7 @@ class EB600(USBMS): supported_platforms = ['windows', 'osx', 'linux'] # Ordered list of supported formats - FORMATS = ['epub', 'prc', 'chm', 'djvu', 'html', 'rtf', 'txt', 'pdf'] + FORMATS = ['epub', 'mobi', 'prc', 'chm', 'djvu', 'html', 'rtf', 'txt', 'pdf'] DRM_FORMATS = ['prc', 'mobi', 'html', 'pdf', 'txt'] VENDOR_ID = [0x1f85] @@ -51,3 +51,12 @@ class EB600(USBMS): return drives +class COOL_ER(EB600): + + FORMATS = ['epub', 'mobi', 'prc', 'pdf', 'txt'] + + VENDOR_NAME = 'COOL-ER' + WINDOWS_MAIN_MEM = 'EREADER' + + EBOOK_DIR_MAIN = 'my docs' + diff --git a/src/calibre/devices/prs500/cli/main.py b/src/calibre/devices/prs500/cli/main.py index 7603acb98a..17226f9895 100755 --- a/src/calibre/devices/prs500/cli/main.py +++ b/src/calibre/devices/prs500/cli/main.py @@ -204,15 +204,27 @@ def main(): _wmi = wmi.WMI() scanner = DeviceScanner(_wmi) scanner.scan() + connected_devices = [] for d in device_plugins(): if scanner.is_device_connected(d): dev = d dev.reset(log_packets=options.log_packets) + connected_devices.append(dev) if dev is None: print >>sys.stderr, 'Unable to find a connected ebook reader.' return 1 + for d in connected_devices: + try: + d.open() + except: + continue + else: + dev = d + break + + try: dev.open() if command == "df": diff --git a/src/calibre/ebooks/metadata/txt.py b/src/calibre/ebooks/metadata/txt.py index 7833fb7263..8dbc0c1453 100644 --- a/src/calibre/ebooks/metadata/txt.py +++ b/src/calibre/ebooks/metadata/txt.py @@ -16,12 +16,12 @@ def get_metadata(stream, extract_cover=True): mdata = u'' for x in range(0, 4): - line = stream.readline().decode('utf-8') + line = stream.readline().decode('utf-8', 'replace') if line == '': break else: mdata += line - + mo = re.search('(?u)^[ ]*(?P.+)[ ]*(\n{3}|(\r\n){3}|\r{3})[ ]*(?P<author>.+)[ ]*(\n|\r\n|\r)$', mdata) if mo != None: mi.title = mo.group('title') diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index ffbcb2e9e2..1f0b315df6 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -89,33 +89,39 @@ class DeviceManager(Thread): self.current_job = None self.scanner = DeviceScanner() + def do_connect(self, connected_devices): + if iswindows: + import pythoncom + pythoncom.CoInitialize() + try: + for dev in connected_devices: + dev.reset() + try: + dev.open() + except: + print 'Unable to open device', dev + traceback.print_exc() + continue + self.device = dev + self.device_class = dev.__class__ + self.connected_slot(True) + break + finally: + if iswindows: + pythoncom.CoUninitialize() + + def detect_device(self): self.scanner.scan() + connected_devices = [] for device in self.devices: connected = self.scanner.is_device_connected(device[0]) - if connected and not device[1]: - if device[2]: - continue - try: - dev = device[0] - dev.reset() - if iswindows: - import pythoncom - pythoncom.CoInitialize() - try: - dev.open() - finally: - if iswindows: - pythoncom.CoUninitialize() - self.device = dev - self.device_class = dev.__class__ - self.connected_slot(True) - except: - print 'Unable to open device' - traceback.print_exc() - finally: - device[1] = True + if connected and not device[1] and not device[2]: + # If connected and not showing in GUI and not ejected + connected_devices.append(device[0]) + device[1] = True elif not connected and device[1]: + # Disconnected but showing in GUI while True: try: job = self.jobs.get_nowait() @@ -126,6 +132,8 @@ class DeviceManager(Thread): self.device = None self.connected_slot(False) device[1] ^= True + if connected_devices: + self.do_connect(connected_devices) def umount_device(self): if self.device is not None: