def run_configure(args):
    """Run a script to configure the current node."""
    config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH

    config_file_exists = False
    # if the config path is `-` then it's stdout
    if config_path != '-':
        config_file_exists = os.path.exists(config_path)

    if config_file_exists and not args.yes:
        want = input_on_stderr('Config file `{}` exists, do you want to '
                               'override it? (cannot be undone) [y/N]: '.format(config_path))
        if want != 'y':
            return

    conf = copy.deepcopy(bigchaindb.config)

    # select the correct config defaults based on the backend
    print('Generating default configuration for backend {}'
          .format(args.backend), file=sys.stderr)
    database_keys = bigchaindb._database_keys_map[args.backend]
    conf['database'] = bigchaindb._database_map[args.backend]

    if not args.yes:
        for key in ('bind', ):
            val = conf['server'][key]
            conf['server'][key] = input_on_stderr('API Server {}? (default `{}`): '.format(key, val), val)

        for key in ('scheme', 'host', 'port'):
            val = conf['wsserver'][key]
            conf['wsserver'][key] = input_on_stderr('WebSocket Server {}? (default `{}`): '.format(key, val), val)

        for key in database_keys:
            val = conf['database'][key]
            conf['database'][key] = input_on_stderr('Database {}? (default `{}`): '.format(key, val), val)

        for key in ('host', 'port'):
            val = conf['tendermint'][key]
            conf['tendermint'][key] = input_on_stderr('Tendermint {}? (default `{}`)'.format(key, val), val)

    if config_path != '-':
        bigchaindb.config_utils.write_config(conf, config_path)
    else:
        print(json.dumps(conf, indent=4, sort_keys=True))
    print('Configuration written to {}'.format(config_path), file=sys.stderr)
    print('Ready to go!', file=sys.stderr)
def run_configure ( args ) : config_path = args . config or bigchaindb . config_utils . CONFIG_DEFAULT_PATH config_file_exists = False if config_path != '-' : config_file_exists = os . path . exists ( config_path ) if config_file_exists and not args . yes : want = input_on_stderr ( 'Config file `{}` exists, do you want to ' 'override it? (cannot be undone) [y/N]: ' . format ( config_path ) ) if want != 'y' : return conf = copy . deepcopy ( bigchaindb . config ) print ( 'Generating default configuration for backend {}' . format ( args . backend ) , file = sys . stderr ) database_keys = bigchaindb . _database_keys_map [ args . backend ] conf [ 'database' ] = bigchaindb . _database_map [ args . backend ] if not args . yes : for key in ( 'bind' , ) : val = conf [ 'server' ] [ key ] conf [ 'server' ] [ key ] = input_on_stderr ( 'API Server {}? (default `{}`): ' . format ( key , val ) , val ) for key in ( 'scheme' , 'host' , 'port' ) : val = conf [ 'wsserver' ] [ key ] conf [ 'wsserver' ] [ key ] = input_on_stderr ( 'WebSocket Server {}? (default `{}`): ' . format ( key , val ) , val ) for key in database_keys : val = conf [ 'database' ] [ key ] conf [ 'database' ] [ key ] = input_on_stderr ( 'Database {}? (default `{}`): ' . format ( key , val ) , val ) for key in ( 'host' , 'port' ) : val = conf [ 'tendermint' ] [ key ] conf [ 'tendermint' ] [ key ] = input_on_stderr ( 'Tendermint {}? (default `{}`)' . format ( key , val ) , val ) if config_path != '-' : bigchaindb . config_utils . write_config ( conf , config_path ) else : print ( json . dumps ( conf , indent = 4 , sort_keys = True ) ) print ( 'Configuration written to {}' . format ( config_path ) , file = sys . stderr ) print ( 'Ready to go!' , file = sys . stderr )
Run a script to configure the current node.