From 7e45095b009c541d8928a8ad6e99f33bf87a15fb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 30 Nov 2009 12:49:30 -0700 Subject: [PATCH] Fix #4080 (Can't SAVE TO DISK from DEVICE) --- Changelog.yaml | 3 +++ src/calibre/devices/interface.py | 4 ++++ src/calibre/devices/prs505/driver.py | 1 + src/calibre/ebooks/oeb/base.py | 2 +- src/calibre/gui2/device.py | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog.yaml b/Changelog.yaml index 7e8cd4b162..0de35f324c 100644 --- a/Changelog.yaml +++ b/Changelog.yaml @@ -34,6 +34,9 @@ tickets: [4040] bug fixes: + - title: "Fix bug that prevented saving of books from a connected device to your computer on windows, for non SONY devices" + tickets: [4080] + - title: Reorganize Dutch language news sources into Belgium and Netherlands categories tickets: [4098] diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index a107129242..01cb109d7b 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -5,6 +5,7 @@ Define the minimum interface that a device backend must satisfy to be used in the GUI. A device backend must subclass the L{Device} class. See prs500.py for a backend that implement the Device interface for the SONY PRS500 Reader. """ +import os from calibre.customize import Plugin @@ -29,6 +30,9 @@ class DevicePlugin(Plugin): THUMBNAIL_HEIGHT = 68 # Height for thumbnails on device # Whether the metadata on books can be set via the GUI. CAN_SET_METADATA = True + #: Path separator for paths to books on device + path_sep = os.sep + def reset(self, key='-1', log_packets=False, report_progress=None) : """ diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index 8e68691589..a988e2e138 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -26,6 +26,7 @@ class PRS505(CLI, Device): description = _('Communicate with the Sony PRS-300/505/500 eBook reader.') author = _('Kovid Goyal and John Schember') supported_platforms = ['windows', 'osx', 'linux'] + path_sep = '/' FORMATS = ['epub', 'lrf', 'lrx', 'rtf', 'pdf', 'txt'] diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 11dab5c102..56fa48d32f 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -799,7 +799,7 @@ class Manifest(object): try: data = etree.fromstring(data) except etree.XMLSyntaxError, err: - self.log.exception('Initial parse failed:') + self.oeb.log.exception('Initial parse failed:') repl = lambda m: ENTITYDEFS.get(m.group(1), m.group(0)) data = ENTITY_RE.sub(repl, data) try: diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index b03101b23e..6fff0444a5 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -248,7 +248,7 @@ class DeviceManager(Thread): def _save_books(self, paths, target): '''Copy books from device to disk''' for path in paths: - name = path.rpartition('/')[2] + name = path.rpartition(getattr(self.device, 'path_sep', '/'))[2] dest = os.path.join(target, name) if os.path.abspath(dest) != os.path.abspath(path): f = open(dest, 'wb')