1
0
Fork 0

tools: wasptool: Hide the stack trace on pexpect timeout

The default pexpect exception dump is verbose and potentially useful if
you know how to read it... but let's handle timeouts in a friendlier way.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2020-10-10 21:06:32 +01:00
parent b6357ad4d8
commit 2839a042be

View file

@ -279,8 +279,17 @@ if __name__ == '__main__':
console = pexpect.spawn(pynus, encoding='UTF-8')
if args.verbose:
console.logfile = sys.stdout
else:
console.logfile = io.StringIO()
try:
console.expect('Connect.*\(([0-9A-F:]*)\)')
except pexpect.exceptions.TIMEOUT:
print('ERROR: Cannot find suitable wasp-os device')
if not args.verbose:
print_log(console.logfile)
sys.exit(1)
console.expect('Connect.*\(([0-9A-F:]*)\)')
macaddr = console.match.group(1)
console.expect('Exit console using Ctrl-X')
time.sleep(0.5)