diff --git a/cmd.py b/cmd.py index 2d68db561b..a1a14f0e07 100755 --- a/cmd.py +++ b/cmd.py @@ -5,7 +5,7 @@ import argparse import json import base64 -from trezorlib.client import TrezorClient +from trezorlib.client import TrezorClientDebug from trezorlib.api_blockchain import BlockchainApi from trezorlib.protobuf_json import pb2json @@ -319,7 +319,7 @@ def main(): return transport = get_transport(args.transport, args.path) - client = TrezorClient(transport) + client = TrezorClientDebug(transport) client.set_tx_func(BlockchainApi().get_tx) cmds = Commands(client) diff --git a/trezorlib/client.py b/trezorlib/client.py index 67b6fb5738..73816e0b50 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -63,13 +63,9 @@ class BaseClient(object): def call_raw(self, msg): try: - print "SENDING", pprint(msg) self.transport.session_begin() - self.transport.write(msg) resp = self.transport.read_blocking() - print "RECEIVED", pprint(resp) - finally: self.transport.session_end() @@ -105,6 +101,13 @@ class BaseClient(object): def close(self): self.transport.close() +class DebugWireMixin(object): + def call_raw(self, msg): + print "SENDING", pprint(msg) + resp = super(DebugWireMixin, self).call_raw(msg) + print "RECEIVED", pprint(resp) + return resp + class TextUIMixin(object): # This class demonstrates easy test-based UI # integration between the device and wallet. @@ -179,9 +182,7 @@ class DebugLinkMixin(object): return resp def call(self, msg): - print "SENDING", pprint(msg) ret = super(DebugLinkMixin, self).call(msg) - print "RECEIVED", pprint(ret) if self.expected_responses != None and len(self.expected_responses): raise Exception("Some of expected responses didn't come from device: %s" % \ @@ -501,7 +502,10 @@ class ProtocolMixin(object): class TrezorClient(ProtocolMixin, TextUIMixin, BaseClient): pass -class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, BaseClient): +class TrezorClientDebug(ProtocolMixin, TextUIMixin, DebugWireMixin, BaseClient): + pass + +class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, DebugWireMixin, BaseClient): pass '''