1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

Fix client.py and protobuf_json.py for Python 3 support

This commit is contained in:
Roman Zeyde 2017-06-05 22:28:41 +03:00 committed by Pavol Rusnak
parent 9f90179bef
commit a2db5a57f2
2 changed files with 10 additions and 9 deletions

View File

@ -90,7 +90,8 @@ def pprint(msg):
return "<%s> (%d bytes):\n%s" % (msg_class, msg_size, msg)
def log(msg):
sys.stderr.write(b'%s\n' % msg)
sys.stderr.write(msg)
sys.stderr.write('\n')
sys.stderr.flush()
class CallException(Exception):

View File

@ -113,13 +113,13 @@ def pb2json(pb, useFieldNumber=False):
_ftype2js = {
FD.TYPE_DOUBLE: float,
FD.TYPE_FLOAT: float,
FD.TYPE_INT64: long,
FD.TYPE_UINT64: long,
FD.TYPE_INT64: int,
FD.TYPE_UINT64: int,
FD.TYPE_INT32: int,
FD.TYPE_FIXED64: float,
FD.TYPE_FIXED32: float,
FD.TYPE_BOOL: bool,
FD.TYPE_STRING: unicode,
FD.TYPE_STRING: str,
#FD.TYPE_MESSAGE: pb2json, #handled specially
FD.TYPE_BYTES: lambda x: x.encode('string_escape'),
FD.TYPE_UINT32: int,
@ -127,19 +127,19 @@ _ftype2js = {
FD.TYPE_SFIXED32: float,
FD.TYPE_SFIXED64: float,
FD.TYPE_SINT32: int,
FD.TYPE_SINT64: long,
FD.TYPE_SINT64: int,
}
_js2ftype = {
FD.TYPE_DOUBLE: float,
FD.TYPE_FLOAT: float,
FD.TYPE_INT64: long,
FD.TYPE_UINT64: long,
FD.TYPE_INT64: int,
FD.TYPE_UINT64: int,
FD.TYPE_INT32: int,
FD.TYPE_FIXED64: float,
FD.TYPE_FIXED32: float,
FD.TYPE_BOOL: bool,
FD.TYPE_STRING: unicode,
FD.TYPE_STRING: str,
# FD.TYPE_MESSAGE: json2pb, #handled specially
FD.TYPE_BYTES: lambda x: x.decode('string_escape'),
FD.TYPE_UINT32: int,
@ -147,7 +147,7 @@ _js2ftype = {
FD.TYPE_SFIXED32: float,
FD.TYPE_SFIXED64: float,
FD.TYPE_SINT32: int,
FD.TYPE_SINT64: long,
FD.TYPE_SINT64: int,
}
# more monkey patching