def ask_gerrit_username(server, ssh_port=29418):
    """ Run a wizard to try to configure gerrit access

    If that fails, ask the user for its username
    If that fails, give up and suggest upload the public key

    """
    ui.info(ui.green, "Configuring gerrit ssh access ...")
    username = qisys.sh.username()
    if not username:
        username = qisys.interact.ask_string("Please enter your username")
        if not username:
            return
    ui.info("Checking gerrit connection with %s@%s:%i" %
            (username, server, ssh_port))
    if check_gerrit_connection(username, server, ssh_port=ssh_port):
        ui.info("Success")
        return username

    ui.warning("Could not connect to ssh using username", username)
    try_other = qisys.interact.ask_yes_no("Do you want to try with another username?")
    if not try_other:
        return

    username = qisys.interact.ask_string("Please enter your username")
    if not username:
        return

    if check_gerrit_connection(username, server, ssh_port=ssh_port):
        return username
dataset/ETHPy150Open aldebaran/qibuild/python/qisrc/review.py/ask_gerrit_username/original