diff --git a/tools/pb2py b/tools/pb2py index 3e2318dbb4..5188ec078c 100755 --- a/tools/pb2py +++ b/tools/pb2py @@ -2,10 +2,11 @@ # Converts Google's protobuf python definitions of TREZOR wire messages # to plain-python objects as used in TREZOR Core and python-trezor -import sys -import importlib -import os import argparse +import importlib +import logging +import os +import sys def import_pb2(name): @@ -42,7 +43,7 @@ def process_message_imports(descriptor): def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy): - print(" * type %s" % descriptor.name) + logging.debug("Processing message %s", descriptor.name) if is_upy: yield "import protobuf as p" @@ -112,7 +113,7 @@ def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy): def process_enum(descriptor, is_upy): - print(" * enum %s" % descriptor.name) + logging.debug("Processing enum %s", descriptor.name) if is_upy: yield "from micropython import const" @@ -134,8 +135,7 @@ def process_enum(descriptor, is_upy): def process_file(descriptor, protobuf_module, genpath, indexfile, modlist, is_upy): - - print("Processing module %s" % descriptor.name) + logging.info("Processing module %s", descriptor.name) msg_types = import_pb2('messages').MessageType @@ -167,6 +167,8 @@ def write_to_file(genpath, t, out): if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + parser = argparse.ArgumentParser() parser.add_argument('module', help="Name of module to generate") parser.add_argument('genpath', help="Directory for generated source code")