Exemplo n.º 1
0
def main(argv):
    parser = argparse.ArgumentParser()
    for cmd_arg_type in command_arguments.Type:
        cmd_arg_attr = command_arguments.attributes[cmd_arg_type]
        parser.add_argument(*cmd_arg_attr.names, **cmd_arg_attr.kwargs)

    args, unknowns = parse_args_include_unknowns(parser, argv)
    quick_command = get_quick_command(unknowns)

    if args.version:
        print(json.dumps(conf.ICON_VERSIONS, indent=2))
        parser.exit()

    command_arguments.set_raw_commands(args)

    if args.radio_station_target == 'testnet':
        args.radio_station_target = conf.URL_CITIZEN_TESTNET
        args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_TESTNET
    elif args.radio_station_target == 'mainnet':
        args.radio_station_target = conf.URL_CITIZEN_MAINNET
        args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_MAINNET

    if args.configure_file_path:
        conf.Configure().load_configure_json(args.configure_file_path)

    if args.key_convert:
        key_convert()
        parser.exit()

    if args.develop:
        loggers.set_preset_type(loggers.PresetType.develop)
    else:
        loggers.set_preset_type(loggers.PresetType.production)
    logger_preset = loggers.get_preset()
    logger_preset.service_type = args.service_type
    loggers.update_preset(False)
    loggers.update_other_loggers()

    grpc_patcher.monkey_patch()
    async_.thread_monkey_patch()
    async_.concurrent_future_monkey_patch()

    if args.service_type in ("peer", "citizen"):
        start_as_peer(args)
    elif args.service_type == "rest":
        start_as_rest_server(args)
    elif args.service_type == "score":
        start_as_score(args)
    elif args.service_type == "channel":
        start_as_channel(args)
    elif args.service_type == "tool":
        start_as_tool(args, quick_command)
    elif args.service_type == "admin":
        start_as_admin(args, quick_command)
    else:
        print(
            f"not supported service type {args.service_type}\ncheck loopchain help.\n"
        )
        parser.print_help()
Exemplo n.º 2
0
def main(argv):
    parser = argparse.ArgumentParser()
    for cmd_arg_type in command_arguments.Type:
        cmd_arg_attr = command_arguments.attributes[cmd_arg_type]
        parser.add_argument(*cmd_arg_attr.names, **cmd_arg_attr.kwargs)

    args = parser.parse_args(argv)
    command_arguments.set_raw_commands(args)

    if args.radio_station_target == 'testnet':
        args.radio_station_target = conf.URL_CITIZEN_TESTNET
        args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_TESTNET
    elif args.radio_station_target == 'mainnet':
        args.radio_station_target = conf.URL_CITIZEN_MAINNET
        args.configure_file_path = conf.CONF_PATH_LOOPCHAIN_MAINNET

    if args.configure_file_path:
        conf.Configure().load_configure_json(args.configure_file_path)

    if args.develop:
        loggers.set_preset_type(loggers.PresetType.develop)
    else:
        loggers.set_preset_type(loggers.PresetType.production)
    logger_preset = loggers.get_preset()
    logger_preset.service_type = args.service_type
    loggers.update_preset(False)
    loggers.update_other_loggers()

    grpc_patcher.monkey_patch()
    async .thread_monkey_patch()
    async .concurrent_future_monkey_patch()

    if args.service_type == "peer":
        start_as_peer(args, conf.NodeType.CommunityNode)
    elif args.service_type == "citizen":
        start_as_peer(args, conf.NodeType.CitizenNode)
    elif args.service_type == "rs" or args.service_type == "radiostation":
        start_as_rs(args)
    elif args.service_type == "rest":
        start_as_rest_server(args)
    elif args.service_type == "rest-rs":
        start_as_rest_server_rs(args)
    elif args.service_type == "score":
        start_as_score(args)
    elif args.service_type == "channel":
        start_as_channel(args)
    elif args.service_type == "tool":
        start_as_tool(args)
    elif args.service_type == "admin":
        start_as_admin(args)
    else:
        print(
            f"not supported service type {args.service_type}\ncheck loopchain help.\n"
        )
        os.system("python3 ./loopchain.py -h")