Пример #1
0
def links(handler):
    for p in CONFIG.keys():
        handler.response.write('<a href="login/{p}">{p}</a><br />'.format(p=p))
    handler.response.write('<br /><br />')
Пример #2
0
    subprocess.run("chmod u+x {home}/deputy-complete.sh".format(home=home),
                   shell=True)
    bash_command("{home}/deputy-complete.sh".format(home=home))
    printer.info("Done!")


@main.command()
@click.password_option('--password',
                       '-p',
                       type=click.STRING,
                       hide_input=True,
                       confirmation_prompt=True,
                       help=h.PASSWORD)
@click.option('--network',
              '-n',
              type=click.Choice([x for x in CONFIG.keys() if x != "virgin"]),
              default=None,
              help=h.NETWORK)
@click.option('--setting', '-s', type=click.STRING, nargs=2, help=h.SETTING)
@click.pass_context
def set_config(ctx, network, setting, password):
    """
    Store configuration values in a file, e.g. the API key for OpenWeatherMap.
    """
    config = ctx.obj['config']
    printer = ctx.obj['printer']

    if not config["virgin"]:
        if not click.confirm("Override or add to previously set settings?",
                             abort=True):
            return
Пример #3
0
def set_config(ctx, network, setting, password):
    """
    Store configuration values in a file, e.g. the API key for OpenWeatherMap.
    """
    config = ctx.obj['config']
    printer = ctx.obj['printer']

    if not config["virgin"]:
        if not click.confirm("Override or add to previously set settings?",
                             abort=True):
            return

    if not network:
        network = click.prompt("Please enter the network you wish to set")
        if network not in CONFIG:
            network = click.prompt("Invalid network, select from {}".format(
                list(CONFIG.keys())[1:]))
            if network not in CONFIG:
                raise e.InvalidNetwork("invalid network entered, exiting.")

        config["virgin"] = False

        config[network]["db_name"] = click.prompt(
            "Please enter the name of the postgres database hosting the network"
        )
        config[network]["db_host"] = click.prompt(
            "Please enter the host of the database (probably localhost)")
        config[network]["db_user"] = click.prompt(
            "Please enter the name of the postgres user")
        config[network]["db_password"] = click.prompt(
            "Please enter the password of the postgres user",
            hide_input=True,
            confirmation_prompt=True)

        config[network]["delegate_address"] = click.prompt(
            "Please enter your delegate address")
        config[network]["delegate_pubkey"] = click.prompt(
            "Please enter your delegate pubkey")

        # passphrases are a list: passphrase, encryption status (True means encrypted)
        if click.confirm("Do want to store your passphrase?"):
            config[network]["delegate_passphrase"] = [
                click.prompt("Please enter your delegate passphrase"), False
            ]
        else:
            config[network]["delegate_passphrase"] = None, None

        if click.confirm("Do want to store your second passphrase?"):
            config[network]["delegate_second_passphrase"] = [
                click.prompt("Please enter your delegate second passphrase"),
                False
            ]
        else:
            config[network]["delegate_second_passphrase"] = None, None

        config[network]["share"] = click.prompt(
            "Please enter your share percentage as a ratio (100% = 1, 50% = 0.5)",
            type=float)
        v.share_validator(None, None, config[network]["share"])

        config[network][
            "max_weight"] = config[network]["coin_in_sat"] * click.prompt(
                "Please enter the max balance that a voter may have in {coin} (not {coin}toshi), "
                "use 'inf' if you do not want to set a maximum (remaining staking reward gets distributed over other voters"
                .format(coin=network),
                type=float)
        config[network]["cover_fees"] = click.confirm(
            "Do you wish to cover transaction fees for your voters?")
        config[network]["min_share"] = click.prompt(
            "What is the minimum built up balance a voter needs before receiving a payout?",
            type=float)
        config[network]["rewardswallet"] = click.prompt(
            "To which address should the rewards be sent?", type=str)
        config[network]["message"] = click.prompt(
            "Enter a message to send to your voters on payouts (if you don't want to send a message, leave it empty)"
        )

        if click.confirm("Do you wish to blacklist voters?"):
            want_blacklist = True
            blacklist = config[network]["blacklist"]
            while want_blacklist:
                blacklist.append(
                    click.prompt("enter an address to add to the blacklist"))
                if click.confirm("Do you wish to blacklist more voters?"):
                    want_blacklist = True
                else:
                    want_blacklist = False
            config[network]["blacklist"] = blacklist
        if click.confirm("Do you wish to enable raven logging?"):
            config[network]["raven_dsn"] = click.prompt("Enter your raven DSN")
        else:
            config[network]["raven_dsn"] = None

        if click.confirm(
                "Do you want to setup a database for logging purposes?"):
            config[network]["db_name_{}_admin.".format(
                network
            )] = click.prompt(
                "Please enter the name of the (non-existant) postgres database hosting the administration"
            )
            config[network]["db_host_{}_admin".format(network)] = click.prompt(
                "Please enter the host of the database (probably localhost)")
            config[network]["db_user_{}_admin".format(network)] = click.prompt(
                "Please enter the name of the postgres user")
            config[network]["db_password_{}_admin".format(
                network)] = click.prompt(
                    "Please enter the password of the postgres user",
                    hide_input=True)

    # Incase we are setting a value specifically through the CLI as a shortcut
    else:
        printer.info("Setting {nw}:{key} to {val}".format(nw=network,
                                                          key=setting[0],
                                                          val=setting[1]))
        config[network][setting[0]] = setting[1]

    # Encrypting the passphrases.
    Crypt().encrypt_config(config, network, password, printer)
    printer.info("Saving your settings...")
    pickle.dump(config, open("/tmp/.dpos-CLI.cfg", "wb"))
    printer.info("Saved!")
    return config
Пример #4
0
def links(handler):
    for p in CONFIG.keys():
        handler.response.write('<a href="login/{p}">{p}</a><br />'.format(p=p))
    handler.response.write('<br /><br />')