This commit is contained in:
Kovid Goyal 2007-06-02 16:48:16 +00:00
parent 2a1edb45c6
commit f119bb5994
2 changed files with 8 additions and 3 deletions

View File

@ -428,7 +428,7 @@ class PRS500(Device):
command_number=PathQuery.NUMBER)[0]
if path.endswith('/') and path != '/':
path = path[:-1]
if res.path_not_found :
if res.path_not_found :
raise PathError(path + " does not exist on device")
if res.is_invalid:
raise PathError(path + " is not a valid path")

View File

@ -207,8 +207,11 @@ class stringfield(object):
length = str(self._length_field.__get__(obj))
return obj.unpack(start=self._start, fmt="<"+length+"s")[0]
def __set__(self, obj, val):
val = str(val)
def __set__(self, obj, val):
if isinstance(val, unicode):
val = val.encode('utf8')
else:
val = str(val)
obj.pack(val, start=self._start, fmt="<"+str(len(val))+"s")
def __repr__(self):
@ -480,6 +483,8 @@ class PathCommand(Command):
path = stringfield(path_length, start=20) #: The path this query is about
def __init__(self, path, number, path_len_at_byte=16):
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 = path
self.type = 0x01