protob: regenerate, fix using old failure codes

This commit is contained in:
Pavol Rusnak 2017-06-18 23:14:28 +02:00
parent e33f4d7612
commit de2f9e7c14
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 29 additions and 29 deletions

View File

@ -89,7 +89,7 @@ def get_transport(transport_string, path, **kwargs):
if path == '' or path in d:
return HidTransport(d, **kwargs)
raise CallException(types.Failure_Other, "Device not found")
raise CallException(types.Failure_NotInitialized, "Device not found")
if transport_string == 'udp':
from trezorlib.transport_udp import UdpTransport
@ -109,7 +109,7 @@ def get_transport(transport_string, path, **kwargs):
if path == '' or d['path'] == binascii.hexlify(path):
return BridgeTransport(d, **kwargs)
raise CallException(types.Failure_Other, "Device not found")
raise CallException(types.Failure_NotInitialized, "Device not found")
raise NotImplementedError("Unknown transport")
@ -147,7 +147,7 @@ class Commands(object):
if ' ' in value:
value, unit = value.split(' ', 1)
if unit.lower() not in ether_units:
raise CallException(types.Failure_Other, "Unrecognized ether unit %r" % unit)
raise CallException(types.Failure_DataError, "Unrecognized ether unit %r" % unit)
value = int(value) * ether_units[unit.lower()]
else:
value = int(value)
@ -157,7 +157,7 @@ class Commands(object):
if ' ' in gas_price:
gas_price, unit = gas_price.split(' ', 1)
if unit.lower() not in ether_units:
raise CallException(types.Failure_Other, "Unrecognized gas price unit %r" % unit)
raise CallException(types.Failure_DataError, "Unrecognized gas price unit %r" % unit)
gas_price = int(gas_price) * ether_units[unit.lower()]
else:
gas_price = int(gas_price)
@ -251,7 +251,7 @@ class Commands(object):
from PIL import Image
im = Image.open(args.filename)
if im.size != (128, 64):
raise CallException(types.Failure_Other, 'Wrong size of the image')
raise CallException(types.Failure_DataError, 'Wrong size of the image')
im = im.convert('1')
pix = im.load()
img = ''
@ -281,7 +281,7 @@ class Commands(object):
def load_device(self, args):
if not args.mnemonic and not args.xprv:
raise CallException(types.Failure_Other, "Please provide mnemonic or xprv")
raise CallException(types.Failure_DataError, "Please provide mnemonic or xprv")
if args.mnemonic:
mnemonic = ' '.join(args.mnemonic)

View File

@ -380,17 +380,17 @@ class DebugLinkMixin(object):
try:
expected = self.expected_responses.pop(0)
except IndexError:
raise CallException(types.Failure_Other,
raise CallException(types.Failure_UnexpectedMessage,
"Got %s, but no message has been expected" % pprint(msg))
if msg.__class__ != expected.__class__:
raise CallException(types.Failure_Other,
raise CallException(types.Failure_UnexpectedMessage,
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
fields = expected.ListFields() # only filled (including extensions)
for field, value in fields:
if not msg.HasField(field.name) or getattr(msg, field.name) != value:
raise CallException(types.Failure_Other,
raise CallException(types.Failure_UnexpectedMessage,
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
def callback_ButtonRequest(self, msg):

File diff suppressed because one or more lines are too long