コード例 #1
0
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level)

    # Create a new processor thats connect to the validator
    processor = TransactionProcessor(url=args.endpoint)

    # Create handler(s) and associate it with the processor
    # See handlers.py to add more transaction handlers
    handler.add_handlers(processor)

    # Start the processor
    # Provide an easy way to stop the processor with CTRL-C
    try:
        print("henlo")
        processor.start()
        print("welp")
    except Exception as e:
        print(e)
        print("Error. Stopping processor....")
        processor.stop()
コード例 #2
0
ファイル: main.py プロジェクト: crazymaster49/sawtooth-core
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level)

    processor = TransactionProcessor(url=args.connect)

    handler = SettingsTransactionHandler()

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #3
0
ファイル: main.py プロジェクト: obahy/Susereum
def main(args=None):
    """
    Main.

    Raises:
    RunTimeException, connection error
    """

    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.connect)

        log_dir = get_log_dir()
        #use the transaction processor zmq idenity for filename
        log_configuration(log_dir=log_dir,
                          name="code_smell-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        handler = CodeSmellTransactionHandler()

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except RuntimeError as err:
        raise CodeSmellException("Error: {}".format(err))
    finally:
        if processor is not None:
            processor.stop()
コード例 #4
0
def main(args=None):
    '''Entry-point function for the carLogger transaction walletprocessor.'''
    setup_loggers()
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    try:
        # Register the transaction handler and start it.
        processor = TransactionProcessor(url=opts.connect)

        handler = CarLoggerTransactionHandler(sw_namespace)

        processor.add_handler(handler)

        processor.start()

    except KeyboardInterrupt:
        pass
    except SystemExit as err:
        LOGGER.info(err)
        raise err
    except BaseException as err:
        LOGGER.info(err)
        traceback.print_exc(file=sys.stderr)
        sys.exit(1)
    except Exception as err:
        LOGGER.info(err)
コード例 #5
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        init_console_logging(verbose_level=opts.verbose)

        processor = TransactionProcessor(url=opts.connect)
        handler_user = UserTransactionHandler()
        handler_cars = CarsTransactionHandler()
        handler_invitations = InvitationsTransactionHandler()

        processor.add_handler(handler_user)
        processor.add_handler(handler_cars)
        processor.add_handler(handler_invitations)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as err:  # pylint: disable=broad-except
        print("Error: {}".format(err))
    finally:
        if processor is not None:
            processor.stop()
コード例 #6
0
ファイル: main.py プロジェクト: thebeast0407/sawtooth-core
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        init_console_logging(verbose_level=opts.verbose)

        processor = TransactionProcessor(url=opts.endpoint)
        log_config = get_log_config(filename="supplychain_log_config.toml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(log_dir=log_dir,
                              name="supplychain-" +
                              str(processor.zmq_id)[2:-1])

        processor.add_handler(SupplyChainHandler())

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #7
0
ファイル: main.py プロジェクト: feihujiang/sawtooth-core
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.endpoint)
        log_config = get_log_config(filename="intkey_log_config.toml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(
                log_dir=log_dir,
                name="intkey-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        # The prefix should eventually be looked up from the
        # validator's namespace registry.
        handler = IntkeyTransactionHandler()

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #8
0
ファイル: main.py プロジェクト: wu4f/cs410b-src
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level)

    processor = TransactionProcessor(url=args.endpoint)

    handler = TodoTransactionHandler()

    processor.add_handler(handler)

    # Start the processor
    # Provide an easy way to stop the processor with CTRL-C
    try:
        processor.start()
    except Exception as err:
        traceback.print_exc()
        print("Error. Stopping processor....")
        processor.stop()
コード例 #9
0
def main(args=None):

    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None

    try:
        # In docker, the url would be the validator's container name with
        # port 4004
        processor = TransactionProcessor(url=opts.connect)

        log_dir = get_log_dir()
        # use the transaction processor zmq identity for filename
        log_configuration(log_dir=log_dir,
                          name="ca-bc-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=2)

        handler = CAHandler('ca_1')
        processor.add_handler(handler)
        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #10
0
ファイル: main.py プロジェクト: trust-tech/sawtooth-core
def main(args=sys.argv[1:]):
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.endpoint)
        log_config = get_log_config(filename="intkey_log_config.toml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(
                log_dir=log_dir,
                name="intkey-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        # The prefix should eventually be looked up from the
        # validator's namespace registry.
        handler = IntkeyTransactionHandler()

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #11
0
ファイル: main.py プロジェクト: Whiteblock/sawtooth-core
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    arg_config = create_identity_config(args)
    identity_config = load_identity_config(arg_config)
    processor = TransactionProcessor(url=identity_config.connect)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level, processor=processor)

    handler = IdentityTransactionHandler()

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #12
0
ファイル: main.py プロジェクト: harshdonga/Project-Pharma
def main(args = None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        arg_config = create_transfer_config(opts)
        transfer_config = load_transfer_config(arg_config)
        processor = TransactionProcessor(url=transfer_config.connect)
        log_config = get_log_config(filename="transfer_log_config.toml")


        if log_config is None:
            log_config = get_log_config(filename="transfer_log_config.yaml")

        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            log_configuration(
                log_dir=log_dir,
                name="transfer" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        handler = TransferHandler()
        processor.add_handler(handler)
        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print("Error: {}".format(e))
    finally:
        if processor is not None:
            processor.stop()
コード例 #13
0
def main(args=sys.argv[1:]):
    opts = parse_args(args)

    processor = TransactionProcessor(url=opts.endpoint)
    log_config = get_log_config(filename="intkey_log_config.toml")
    if log_config is not None:
        log_configuration(log_config=log_config)
    else:
        log_dir = get_log_dir()
        # use the transaction processor zmq identity for filename
        log_configuration(log_dir=log_dir,
                          name="intkey_python-" + str(processor.zmq_id)[2:-1])

    init_console_logging(verbose_level=opts.verbose)

    # The prefix should eventually be looked up from the
    # validator's namespace registry.
    intkey_prefix = hashlib.sha512('intkey'.encode()).hexdigest()[0:6]
    handler = IntkeyTransactionHandler(namespace_prefix=intkey_prefix)

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #14
0
def main(args=None):
    if args is None:
        args = sys.argv[3:]  # considering the starting command is `python3 main.py` and then additional arguments

    opts = parse_args(args)
    processor = None

    try:
        processor = TransactionProcessor(url=opts.connect)
        log_config = get_log_config(filename=tp_config_name+"_log_config.toml")
        # If no toml, try loading yaml
        if log_config is None:
            log_config = get_log_config(filename=tp_config_name+"_log_config.yaml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(
                log_dir=log_dir,
                name=tp_config_name+"-" + str(processor.zmq_id)[2:-1])
        init_console_logging(verbose_level=opts.verbose)
        # The prefix should eventually be looked up from the
        # validator's namespace registry.
        handler = Manufacturing()
        processor.add_handler(handler)
        processor.start()

    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #15
0
ファイル: main.py プロジェクト: MarkGisi/sparts-0.2
def main(args=sys.argv[1:]):
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.endpoint)
        log_config = get_log_config(filename="supplier_log_config.toml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(log_dir=log_dir,
                              name="supplier-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        # The prefix should eventually be looked up from the
        # validator's namespace registry.
        supplier_prefix = hashlib.sha512(
            'supplier'.encode("utf-8")).hexdigest()[0:6]
        handler = SupplierTransactionHandler(namespace_prefix=supplier_prefix)

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print("Error: {}".format(e))
    finally:
        if processor is not None:
            processor.stop()
コード例 #16
0
ファイル: main.py プロジェクト: feihujiang/sawtooth-core
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level)

    processor = TransactionProcessor(url=args.endpoint)

    handler = SettingsTransactionHandler()

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #17
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.connect)
        log_config = get_log_config(filename="consent_log_config.toml")

        # If no toml, try loading yaml
        if log_config is None:
            log_config = get_log_config(filename="consent_log_config.yaml")

        if log_config is not None:
            log_configuration(log_config=log_config)
        # else:
        #     log_dir = get_log_dir()
        init_console_logging(verbose_level=opts.verbose)

        handler = ConsentTransactionHandler(TP_PREFFIX_HEX6)

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except, invalid-name
        print("Error: {}".format(e), file=sys.stderr)
    finally:
        if processor is not None:
            processor.stop()
コード例 #18
0
def main(args=sys.argv[1:]):
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.endpoint)
        log_config = get_log_config(filename="part_log_config.toml")
        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()

            log_configuration(log_dir=log_dir,
                              name="part-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        part_prefix = hashlib.sha512('part'.encode("utf-8")).hexdigest()[0:6]
        handler = PartTransactionHandler(namespace_prefix=part_prefix)

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print("Error: {}".format(e))
    finally:
        if processor is not None:
            processor.stop()
コード例 #19
0
ファイル: main.py プロジェクト: hashblock/hashblock-exchange
def main(prog_name=os.path.basename(sys.argv[0]), args=None,
         with_loggers=True):
    if args is None:
        args = sys.argv[1:]
    parser = create_parser(prog_name)
    args = parser.parse_args(args)

    arg_config = create_settings_config(args)
    setting_config = load_settings_config(arg_config)
    processor = TransactionProcessor(url=setting_config.connect)

    if with_loggers is True:
        if args.verbose is None:
            verbose_level = 0
        else:
            verbose_level = args.verbose
        setup_loggers(verbose_level=verbose_level, processor=processor)

    my_logger = logging.getLogger(__name__)
    my_logger.debug("Processor loaded")

    handler = SettingTransactionHandler()

    processor.add_handler(handler)

    my_logger.debug(
        "Hashblock setting instantiated, starting setting processor thread...")

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #20
0
def main():
    processor = TransactionProcessor(url='tcp://validator:4004')

    handler = SimpleWalletTransactionHandler(sw_namespace)

    processor.add_handler(handler)

    processor.start()
コード例 #21
0
def main(url):
    processor = TransactionProcessor(url=url)
    processor.add_handler(PublishMeasurementTransactionHandler())
    processor.add_handler(IssueGGOTransactionHandler())
    processor.add_handler(TransferGGOTransactionHandler())
    processor.add_handler(SplitGGOTransactionHandler())
    processor.add_handler(RetireGGOTransactionHandler())
    processor.add_handler(SettlementHandler())
    processor.start()
コード例 #22
0
def main(args=None):
    processor = TransactionProcessor(url="tcp://validator:4004")
    handler = SetGetTransactionHandler()
    # Adds a transaction family handler :param handler: the handler to
    # be added :type handler: TransactionHandler
    processor.add_handler(handler)
    #Connects the transaction processor to a validator and starts listening
    #for requests and routing them to an appropriate transaction handler.
    processor.start()
コード例 #23
0
class Processor:
    def __init__(self, handler, address):
        self._processor = TransactionProcessor(url=address)
        self._processor.add_handler(handler)

    def start(self):
        self._processor.start()

    def stop(self):
        self._processor.stop()
コード例 #24
0
def main():
    # In docker, the url would be the validator's container name with
    # port 4004
    processor = TransactionProcessor(url='tcp://validator-bgx-с1-1:4104')

    handler = DQTransactionHandler()

    processor.add_handler(handler)

    processor.start()
コード例 #25
0
def main(validator_url):
    # In docker, the url would be the validator's container name with port 4004

    processor = TransactionProcessor(url=validator_url)

    handler = XoTransactionHandler(XO_NAMESPACE)

    processor.add_handler(handler)

    processor.start()
コード例 #26
0
ファイル: main.py プロジェクト: saubanbinusman/block-ons
def main():
    # In docker, the url would be the validator's container name with
    # port 4004
    processor = TransactionProcessor(url='tcp://127.0.0.1:4004')

    handler = BlockONSTXHandler("007007")

    processor.add_handler(handler)

    processor.start()
コード例 #27
0
def main(args=sys.argv[1:]):
    # The prefix should eventually be looked up from the
    # validator's namespace registry.
    intkey_prefix = hashlib.sha512('intkey').hexdigest()[0:6]

    processor = TransactionProcessor(url=args[0] + ":40000")

    handler = IntkeyTransactionHandler(namespace_prefix=intkey_prefix)
    processor.add_handler(handler)

    processor.start()
コード例 #28
0
def main(args=sys.argv[1:]):
    processor = TransactionProcessor(url=args[0])

    handler = ConfigurationTransactionHandler()

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #29
0
def main():
    # In docker, the url would be the validator's container name with
    # port 4004
    print("i started")
    print("processor becomes txp on localhost")
    processor = TransactionProcessor(url='tcp://127.0.0.1:4004')
    handler = HelloTransactionHandler()
    print("handler has gotten a value")
    processor.add_handler(handler)
    print("procesor.add_handler(handler)done")
    print("connected with validator")
    processor.start()
    print("i got to the end")
コード例 #30
0
def main():
    try:
        processor = TransactionProcessor(url='tcp://localhost:4004')
        handler = WalletHandler(SW_NAME_SPACE)
        processor.add_handler(handler)
        processor.start()
    except KeyboardInterrupt:
        pass
    except SystemExit as err:
        raise err
    except BaseException as err:
        traceback.print_exc(file=sys.stderr)
        sys.exit(1)
コード例 #31
0
def main():
    try:
        processor = TransactionProcessor(url='tcp://127.0.0.1:4004')
        handler = SawtoothTestTransactionHandler(sw_namespace)
        processor.add_handler(handler)
        processor.start()
    except KeyboardInterrupt:
        pass
    except SystemExit as err:
        raise err
    except BaseException as err:
        traceback.print_exc(file=sys.stderr)
        sys.exit(1)
コード例 #32
0
def main():
    # In docker, the url would be the validator's container name with
    # port 4004
    processor = TransactionProcessor(url=VALIDATOR_ADDRESS)

    handler = IoT_TransactionHandler()

    processor.add_handler(handler)

    print('Starting IoT transaction processor')
    print('Connecting to sawtooth validator at ' + VALIDATOR_ADDRESS)

    processor.start()
コード例 #33
0
ファイル: main.py プロジェクト: Scott-mi/BlockchainFormation
def main():
    # Set logging
    init_console_logging(verbose_level=2)

    # Create transaction processor class with specified address of the validator
    processor = TransactionProcessor(url='tcp://127.0.0.1:4004')

    # We have to instantiate our self implemented handler class which encodes the main part of the application's logic
    handler = BenchmarkHandler('benchcontract')

    # Now we have to add our handler to the processor
    processor.add_handler(handler)

    # Start the processor
    print('starting benchcontract processor...')
    processor.start()
コード例 #34
0
ファイル: main.py プロジェクト: feihujiang/sawtooth-core
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)

    init_console_logging(verbose_level=opts.verbose)

    processor = TransactionProcessor(url=opts.endpoint)

    handler = ValidatorRegistryTransactionHandler()

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #35
0
ファイル: main.py プロジェクト: jsmitchell/sawtooth-core
def main(args=sys.argv[1:]):
    opts = parse_args(args)

    init_console_logging(verbose_level=opts.verbose)

    processor = TransactionProcessor(url=opts.endpoint)

    # The prefix should eventually be looked up from the
    # validator's namespace registry.
    xo_prefix = hashlib.sha512('xo'.encode("utf-8")).hexdigest()[0:6]
    handler = XoTransactionHandler(namespace_prefix=xo_prefix)

    processor.add_handler(handler)

    try:
        processor.start()
    except KeyboardInterrupt:
        pass
    finally:
        processor.stop()
コード例 #36
0
ファイル: main.py プロジェクト: Whiteblock/sawtooth-core
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.connect)
        log_config = get_log_config(filename="battleship_log_config.toml")

        # If no toml, try loading yaml
        if log_config is None:
            log_config = get_log_config(filename="battleship_log_config.yaml")

        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(
                log_dir=log_dir,
                name="battleship-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        # The prefix should eventually be looked up from the
        # validator's namespace registry.
        battle_ship_prefix = \
            hashlib.sha512('battleship'.encode("utf-8")).hexdigest()[0:6]
        handler = \
            BattleshipTransactionHandler(namespace_prefix=battle_ship_prefix)

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e))
    finally:
        if processor is not None:
            processor.stop()
コード例 #37
0
ファイル: main.py プロジェクト: XavoerJ/education
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        processor = TransactionProcessor(url=opts.connect)

        init_console_logging(verbose_level=opts.verbose)

        handler = TunachainTransactionHandler()

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as err:  # pylint: disable=broad-except
        print("Error: {}".format(err))
    finally:
        if processor is not None:
            processor.stop()
コード例 #38
0
ファイル: main.py プロジェクト: Whiteblock/sawtooth-core
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    opts = parse_args(args)
    processor = None
    try:
        arg_config = create_xo_config(opts)
        xo_config = load_xo_config(arg_config)
        processor = TransactionProcessor(url=xo_config.connect)
        log_config = get_log_config(filename="xo_log_config.toml")

        # If no toml, try loading yaml
        if log_config is None:
            log_config = get_log_config(filename="xo_log_config.yaml")

        if log_config is not None:
            log_configuration(log_config=log_config)
        else:
            log_dir = get_log_dir()
            # use the transaction processor zmq identity for filename
            log_configuration(
                log_dir=log_dir,
                name="xo-" + str(processor.zmq_id)[2:-1])

        init_console_logging(verbose_level=opts.verbose)

        handler = XoTransactionHandler()

        processor.add_handler(handler)

        processor.start()
    except KeyboardInterrupt:
        pass
    except Exception as e:  # pylint: disable=broad-except
        print("Error: {}".format(e))
    finally:
        if processor is not None:
            processor.stop()