From 5899d649cd366f953db356041bc6dd8b8a5e1f11 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 12 Jul 2016 19:09:31 -0400 Subject: Make username a command-line option, default "so" as it used to be. --- projects/hsm/cryptech_upload | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/projects/hsm/cryptech_upload b/projects/hsm/cryptech_upload index 64b9440..0c3f6fc 100755 --- a/projects/hsm/cryptech_upload +++ b/projects/hsm/cryptech_upload @@ -76,6 +76,12 @@ def parse_args(): help = "Location of firmware tarball", ) + parser.add_argument("--username", + choices = ("so", "wheel"), + default = "so", + help = "Username to use when logging into the HSM", + ) + actions = parser.add_mutually_exclusive_group(required = True) actions.add_argument("--fpga", action = "store_true", @@ -128,15 +134,11 @@ def _execute(dst, cmd): _write(dst, "\r") prompt = _read(dst) if prompt.endswith("Username: "): - if sys.version_info[0] > 2: - user = input("Username (so, wheel): ") - else: - user = raw_input("Username (so, wheel): ") - _write(dst, user + "\r") + _write(dst, args.username + "\r") prompt = _read(dst) if prompt.endswith("Password: "): if not pin: - pin = getpass.getpass("PIN: ") + pin = getpass.getpass("{} PIN: ".format(args.username)) _write(dst, pin + "\r") prompt = _read(dst) if not prompt.endswith(("> ", "# ")): @@ -237,6 +239,7 @@ If you got here by accident, ^C now, without answering the PIN prompt. def main(): + global args args = parse_args() if args.bootloader and not args.simon_says_whack_my_bootloader: -- cgit v1.2.3