[check_install.py] Convert to Python 3 (#5831)

- Convert check_install.py script to Python 3
- Reorganize imports per PEP8 standard
- Two blank lines precede functions per PEP8 standard
This commit is contained in:
Joe LeVeque 2020-11-11 10:18:48 -08:00 committed by GitHub
parent 609cbdd0f3
commit e0ebcc0c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python3
import pexpect
import argparse import argparse
import pexpect
import sys import sys
import time import time
def main(): def main():
parser = argparse.ArgumentParser(description='test_login cmdline parser') parser = argparse.ArgumentParser(description='test_login cmdline parser')
@ -21,16 +22,16 @@ def main():
login_prompt = 'sonic login:' login_prompt = 'sonic login:'
passwd_prompt = 'Password:' passwd_prompt = 'Password:'
cmd_prompt = "%s@sonic:~\$ $" % args.u cmd_prompt = "{}@sonic:~\$ $".format(args.u)
grub_selection = "The highlighted entry will be executed" grub_selection = "The highlighted entry will be executed"
i = 0 i = 0
while True: while True:
try: try:
p = pexpect.spawn("telnet 127.0.0.1 %s" % args.p, timeout=600, logfile=sys.stdout) p = pexpect.spawn("telnet 127.0.0.1 {}".format(args.p), timeout=600, logfile=sys.stdout, encoding='utf-8')
break break
except Exception as e: except Exception as e:
print str(e) print(str(e))
i += 1 i += 1
if i == 10: if i == 10:
raise raise