Skip to content

Commit

Permalink
tests/serial-console-connection: reformat using black
Browse files Browse the repository at this point in the history
  • Loading branch information
zeha committed Aug 17, 2024
1 parent 0e7cffd commit 235670b
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions tests/serial-console-connection
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,38 @@ import time
from pexpect import fdpexpect

parser = argparse.ArgumentParser(
description='Connect to serial console to execute stuff',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--port', required=True,
help='serial console device to connect ' +
'to (e.g. /dev/pts/X)')
parser.add_argument('--hostname', default="buster",
help='hostname of the system for login process')
parser.add_argument('--user', default="root",
help='user name to use for login')
parser.add_argument('--password', default="grml",
help='password for login')
parser.add_argument('--timeout', default="180", type=int,
help='Maximum time for finding the login prompt, in seconds')
parser.add_argument('--tries', default="12", type=int,
help='Number of retries for finding the login prompt')
parser.add_argument('--poweroff', action="store_true", default=False,
help='send "poweroff" command after all other commands')
parser.add_argument('command', nargs='+',
help='command to execute after logging in')

description="Connect to serial console to execute stuff",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"--port",
required=True,
help="serial console device to connect " + "to (e.g. /dev/pts/X)",
)
parser.add_argument(
"--hostname", default="buster", help="hostname of the system for login process"
)
parser.add_argument("--user", default="root", help="user name to use for login")
parser.add_argument("--password", default="grml", help="password for login")
parser.add_argument(
"--timeout",
default="180",
type=int,
help="Maximum time for finding the login prompt, in seconds",
)
parser.add_argument(
"--tries",
default="12",
type=int,
help="Number of retries for finding the login prompt",
)
parser.add_argument(
"--poweroff",
action="store_true",
default=False,
help='send "poweroff" command after all other commands',
)
parser.add_argument("command", nargs="+", help="command to execute after logging in")


def print_ser_lines(ser):
Expand Down Expand Up @@ -83,7 +95,7 @@ def main():
success = True
break
except Exception as except_inst:
print("Login failure (try %s):" % (i, ), except_inst, file=sys.stderr)
print("Login failure (try %s):" % (i,), except_inst, file=sys.stderr)
time.sleep(5)
if time.time() - ts_start > args.timeout:
print("Timeout reached waiting for login prompt", file=sys.stderr)
Expand All @@ -106,5 +118,6 @@ def main():
if not success:
sys.exit(1)


if __name__ == "__main__":
main()

0 comments on commit 235670b

Please sign in to comment.