mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 11:28:14 +00:00
use isinstance to detect whether result is protobuf message
This commit is contained in:
parent
1727b9a9b6
commit
5ffc700f0c
@ -75,8 +75,8 @@ def cli(ctx, transport, path, verbose, is_json):
|
||||
@cli.resultcallback()
|
||||
def print_result(res, transport, path, verbose, is_json):
|
||||
if is_json:
|
||||
if hasattr(res, '__module__') and res.__module__ == 'messages_pb2':
|
||||
from google.protobuf import json_format
|
||||
from google.protobuf import json_format, message
|
||||
if isinstance(res, message.Message):
|
||||
click.echo(json_format.MessageToJson(res, preserving_proto_field_name=True))
|
||||
else:
|
||||
click.echo(json.dumps(res, sort_keys=True, indent=4))
|
||||
|
Loading…
Reference in New Issue
Block a user