From e456f6e828f394c0f4e113ec4d71f429be1a162d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Nov 2006 22:59:31 +0000 Subject: [PATCH] Made cp command more usable and isolated problem in OSX to bulk reads --- libprs500/__init__.py | 2 +- libprs500/communicate.py | 7 ++----- scripts/prs500.py | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/libprs500/__init__.py b/libprs500/__init__.py index 2da677971a..15171003fb 100644 --- a/libprs500/__init__.py +++ b/libprs500/__init__.py @@ -20,6 +20,6 @@ the following rule in C{/etc/udev/rules.d/90-local.rules} :: BUS=="usb", SYSFS{idProduct}=="029b", SYSFS{idVendor}=="054c", MODE="660", GROUP="plugdev" You may have to adjust the GROUP and the location of the rules file to suit your distribution. """ -VERSION = "0.2" +VERSION = "0.2.1" __docformat__ = "epytext" __author__ = "Kovid Goyal " diff --git a/libprs500/communicate.py b/libprs500/communicate.py index e52ebca546..1a9fab184d 100755 --- a/libprs500/communicate.py +++ b/libprs500/communicate.py @@ -185,10 +185,6 @@ class PRS500Device(object): print >> sys.stderr, "Unable to find Sony Reader. Is it connected?" sys.exit(1) self.handle = self.device.open() - if sys.platform == 'darwin' : - # For some reason, Mac OS X doesn't set the - # configuration automatically like Linux does. - self.handle.setConfiguration(1) self.handle.claimInterface(self.device_descriptor.interface_id) self.handle.reset() res = self._send_validated_command(GetUSBProtocolVersion()) @@ -276,6 +272,7 @@ class PRS500Device(object): Read in C{bytes} bytes via a bulk transfer in packets of size S{<=} C{packet_size} @param data_type: an object of type type. The data packet is returned as an object of type C{data_type}. @return: A list of packets read from the device. Each packet is of type data_type + @todo: Figure out how to make bulk reads work in OSX """ def bulk_read_packet(data_type=Answer, size=0x1000): data = data_type(self.handle.bulkRead(PRS500Device.PRS500_BULK_IN_EP, size)) @@ -445,7 +442,7 @@ class PRS500Device(object): """ Create a file at path - @todo: Update file modification time if it exists + @todo: Update file modification time if file already exists """ if path.endswith("/") and len(path) > 1: path = path[:-1] exists, file = self._exists(path) diff --git a/scripts/prs500.py b/scripts/prs500.py index 4119357513..41ec4d6cca 100755 --- a/scripts/prs500.py +++ b/scripts/prs500.py @@ -212,9 +212,9 @@ def main(): info(dev) elif command == "cp": usage="usage: %prog cp [options] source destination\n\n"+\ - "One of source or destination must be a path on the device. Device paths have the form:\n"+\ - "device:mountpoint/my/path\n"+\ - "where mountpoint is one of /, a: or b:\n"+\ + "One of source or destination must be a path on the device. \n\nDevice paths have the form\n"+\ + "prs500:mountpoint/my/path\n"+\ + "where mountpoint is one of /, a: or b:\n\n"+\ "source must point to a file for which you have read permissions\n"+\ "destination must point to a file or directory for which you have write permissions" parser = OptionParser(usage=usage) @@ -222,7 +222,7 @@ def main(): if len(args) != 2: parser.print_help() sys.exit(1) - if args[0].startswith("device:"): + if args[0].startswith("prs500:"): outfile = args[1] path = args[0][7:] if path.endswith("/"): path = path[:-1] @@ -236,7 +236,7 @@ def main(): sys.exit(1) dev.get_file(path, outfile) outfile.close() - elif args[1].startswith("device:"): + elif args[1].startswith("prs500:"): try: infile = open(args[0], "r") except IOError, e: