You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File "./testproto.py", line 153, in client
printb(a.pack())
File "/home/oscar/env/lib/python2.7/site-packages/suitcase/structure.py", line 303, in pack
return self._packer.pack()
File "/home/oscar/env/lib/python2.7/site-packages/suitcase/structure.py", line 28, in pack
self.write(sio)
File "/home/oscar/env/lib/python2.7/site-packages/suitcase/structure.py", line 41, in write
field.pack(stream)
File "/home/oscar/env/lib/python2.7/site-packages/suitcase/fields.py", line 889, in pack
raise SuitcasePackStructException(e)
suitcase.exceptions.SuitcasePackStructException: pack requires exactly 1 arguments
To make it work I need to change the way self._value is passed to pack:
Original version not working (line 887 in fields.py): stream.write(struct.pack(self.format, *self._value))
Modified version working (same line 887 in fields.py): stream.write(struct.pack(self.format, self._value))
If the fix is ok, BaseVariableByteSequence has the same problem.
ocurero's suggestion is a nice workaround, but it would be great if you could implement a FixedByteSequence(number_of_bytes) field in the next version of suitcase.
Activity
posborne commentedon May 19, 2016
I think
UBInt8Sequenceshould work for this. It appears that it doesn't show up in the docs as it is generated by a factory (https://digidotcom.github.io/python-suitcase/latest/_modules/suitcase/fields.html#BaseFixedByteSequence). It expects a sequence of bytes (e.g.[1, 2, 3, 4, 5, 6, 7, 8]), so some conversion will be required if you have an actual bytes payload.ocurero commentedon May 20, 2016
Thanks Paul!
It works, but something is still wrong. If I try the way you say:
IRM_RACF_GRNAME = BaseFixedByteSequence(lambda x: str(x) + 's', 8)I get the following error:
To make it work I need to change the way self._value is passed to pack:
Original version not working (line 887 in fields.py):
stream.write(struct.pack(self.format, *self._value))Modified version working (same line 887 in fields.py):
stream.write(struct.pack(self.format, self._value))If the fix is ok, BaseVariableByteSequence has the same problem.
v3gard commentedon Oct 5, 2016
ocurero's suggestion is a nice workaround, but it would be great if you could implement a FixedByteSequence(number_of_bytes) field in the next version of suitcase.