(args)
Generate bitcoin.conf configuration
Generate bitcoin.conf configuration
Generate bitcoin . conf configuration
def configure(args):
    """Generate bitcoin.conf configuration"""
    info = config.read_cfg_file(args.cfg, args.cfg_dir)

    if (info is None):
        return

    if (not args.stdout):
        util.print_header("Bitcoin Conf Generator")

    if args.datadir is None:
        home = os.path.expanduser("~")
        path = os.path.join(home, ".bitcoin")
    else:
        path = os.path.abspath(args.datadir)

    conf_file = "bitcoin.conf"
    abs_path = os.path.join(path, conf_file)

    # Network interface
    ifname = config.get_net_if(info)

    # Generate configuration object
    cfg = _gen_cfgs(info, ifname)

    # Load and concatenate pre-existing configurations
    if args.concat and os.path.exists(abs_path):
        with open(abs_path, "r") as fd:
            prev_cfg_text = fd.read()
            cfg.load_text_cfg(prev_cfg_text)

    # Export configurations to text format
    cfg_text = cfg.text()

    # Print configurations to stdout and don't save them
    if (args.stdout):
        print(cfg_text)
        return

    # Proceed to saving configurations
    print("Save {} at {}".format(conf_file, path))

    if (not util.ask_yes_or_no("Proceed?")):
        print("Aborted")
        return

    if not os.path.exists(path):
        os.makedirs(path)

    if os.path.exists(abs_path) and not args.concat:
        if (not util.ask_yes_or_no("File already exists. Overwrite?")):
            print("Aborted")
            return

    with open(abs_path, "w") as fd:
        fd.write(cfg_text)

    print("Saved")

    if (info['setup']['type'] == defs.linux_usb_setup_type):
        print()
        util.fill_print(
            "NOTE: {} was configured assuming the dvbnet interface is "
            "named {}. You can check if this is the case after launching the "
            "receiver by running:".format(conf_file, ifname))
        print("    ip link show | grep dvb\n")
        util.fill_print("If the dvb interfaces are numbered differently, "
                        "please update {} accordingly.".format(conf_file))
    elif (info['setup']['type'] == defs.standalone_setup_type):
        print("\n" + textwrap.fill(
            ("NOTE: {0} was configured assuming the Novra S400 receiver will "
             "be connected to interface {1}. If this is not the case anymore, "
             "please update {0} accordingly.").format(conf_file, ifname)))
def configure ( args ) : info = config . read_cfg_file ( args . cfg , args . cfg_dir ) if ( info is None ) : return if ( not args . stdout ) : util . print_header ( "Bitcoin Conf Generator" ) if args . datadir is None : home = os . path . expanduser ( "~" ) path = os . path . join ( home , ".bitcoin" ) else : path = os . path . abspath ( args . datadir ) conf_file = "bitcoin.conf" abs_path = os . path . join ( path , conf_file ) # Network interface ifname = config . get_net_if ( info ) # Generate configuration object cfg = _gen_cfgs ( info , ifname ) # Load and concatenate pre-existing configurations if args . concat and os . path . exists ( abs_path ) : with open ( abs_path , "r" ) as fd : prev_cfg_text = fd . read ( ) cfg . load_text_cfg ( prev_cfg_text ) # Export configurations to text format cfg_text = cfg . text ( ) # Print configurations to stdout and don't save them if ( args . stdout ) : print ( cfg_text ) return # Proceed to saving configurations print ( "Save {} at {}" . format ( conf_file , path ) ) if ( not util . ask_yes_or_no ( "Proceed?" ) ) : print ( "Aborted" ) return if not os . path . exists ( path ) : os . makedirs ( path ) if os . path . exists ( abs_path ) and not args . concat : if ( not util . ask_yes_or_no ( "File already exists. Overwrite?" ) ) : print ( "Aborted" ) return with open ( abs_path , "w" ) as fd : fd . write ( cfg_text ) print ( "Saved" ) if ( info [ 'setup' ] [ 'type' ] == defs . linux_usb_setup_type ) : print ( ) util . fill_print ( "NOTE: {} was configured assuming the dvbnet interface is " "named {}. You can check if this is the case after launching the " "receiver by running:" . format ( conf_file , ifname ) ) print ( "    ip link show | grep dvb\n" ) util . fill_print ( "If the dvb interfaces are numbered differently, " "please update {} accordingly." . format ( conf_file ) ) elif ( info [ 'setup' ] [ 'type' ] == defs . standalone_setup_type ) : print ( "\n" + textwrap . fill ( ( "NOTE: {0} was configured assuming the Novra S400 receiver will " "be connected to interface {1}. If this is not the case anymore, " "please update {0} accordingly." ) . format ( conf_file , ifname ) ) )