Verified Commit a912657b authored by anarcat's avatar anarcat 💥
Browse files

factor out the "prompt with bell" command

We reuse the "input" vocabulary here though because that's what python
programmers will search for.

This is split out because I need to reuse this elsewhere and want to
avoid duplicating bugs. Here, in particular, the bell output added an
extra newline to the output by mistake. The new implementation is
correct.
parent 2d5a5882
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import paramiko.ssh_exception

from . import ganeti
from . import host
from .ui import input_bell
from .kgb import relay_message as kgb_relay_message


@@ -130,8 +131,7 @@ def wait_for_live(con, delay_up=DEFAULT_DELAY_UP):
                "cannot find a valid SSH key anymore (%s), is your cryptographic token plugged in?",
                e,
            )
            print("\a")
            input("pay attention to your cryptographic token and press enter: ")
            input_bell("pay attention to your cryptographic token and press enter: ")
        # failed to connect to the host
        except (OSError, EOFError) as e:
            logging.error(
@@ -277,8 +277,8 @@ def run_pending_upgrades_with_shutdown(con):
    if ret.failed:
        logging.warning("apt upgrade failed, ignoring error")

    input(
        "confirm packages upgraded correctly before performing reboots\a (press enter to continue): "
    input_bell(
        "confirm packages upgraded correctly before performing reboots, press enter to continue: "
    )
    # logging.info("upgrading openvswitch, networking might be lost")
    # con.run("apt install openvswitch-common openvswitch-security")
+4 −0
Original line number Diff line number Diff line
@@ -277,3 +277,7 @@ def re_include_exclude(
    if include and not re.search(include, content):
        return False
    return True


def input_bell(prompt: str = "press enter to continue: ") -> str:
    return input("\a" + prompt)