mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Made cp command more usable and isolated problem in OSX to bulk reads
This commit is contained in:
parent
6f1767a717
commit
e456f6e828
@ -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 <kovid@kovidgoyal.net>"
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user