mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Fix #92
This commit is contained in:
parent
2a1edb45c6
commit
f119bb5994
@ -428,7 +428,7 @@ class PRS500(Device):
|
|||||||
command_number=PathQuery.NUMBER)[0]
|
command_number=PathQuery.NUMBER)[0]
|
||||||
if path.endswith('/') and path != '/':
|
if path.endswith('/') and path != '/':
|
||||||
path = path[:-1]
|
path = path[:-1]
|
||||||
if res.path_not_found :
|
if res.path_not_found :
|
||||||
raise PathError(path + " does not exist on device")
|
raise PathError(path + " does not exist on device")
|
||||||
if res.is_invalid:
|
if res.is_invalid:
|
||||||
raise PathError(path + " is not a valid path")
|
raise PathError(path + " is not a valid path")
|
||||||
|
@ -207,8 +207,11 @@ class stringfield(object):
|
|||||||
length = str(self._length_field.__get__(obj))
|
length = str(self._length_field.__get__(obj))
|
||||||
return obj.unpack(start=self._start, fmt="<"+length+"s")[0]
|
return obj.unpack(start=self._start, fmt="<"+length+"s")[0]
|
||||||
|
|
||||||
def __set__(self, obj, val):
|
def __set__(self, obj, val):
|
||||||
val = str(val)
|
if isinstance(val, unicode):
|
||||||
|
val = val.encode('utf8')
|
||||||
|
else:
|
||||||
|
val = str(val)
|
||||||
obj.pack(val, start=self._start, fmt="<"+str(len(val))+"s")
|
obj.pack(val, start=self._start, fmt="<"+str(len(val))+"s")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -480,6 +483,8 @@ class PathCommand(Command):
|
|||||||
path = stringfield(path_length, start=20) #: The path this query is about
|
path = stringfield(path_length, start=20) #: The path this query is about
|
||||||
def __init__(self, path, number, path_len_at_byte=16):
|
def __init__(self, path, number, path_len_at_byte=16):
|
||||||
Command.__init__(self, path_len_at_byte+4+len(path))
|
Command.__init__(self, path_len_at_byte+4+len(path))
|
||||||
|
if isinstance(path, unicode):
|
||||||
|
path = path.encode('utf8')
|
||||||
self.path_length = len(path)
|
self.path_length = len(path)
|
||||||
self.path = path
|
self.path = path
|
||||||
self.type = 0x01
|
self.type = 0x01
|
||||||
|
Loading…
x
Reference in New Issue
Block a user