diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-10-21 19:49:48 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-10-21 19:49:48 (GMT) |
| commit | 2b244ec2a3ed612ec6f784ed092549a7174d15c2 (patch) | |
| tree | 807a3e42b281afb1eab11e80561499dabee27ddf /tools | |
| parent | 2bb083744092c28ef580f8abb5ce5e236e793a74 (diff) | |
tools: wasptool: Improve error reporting if we can't sync
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/wasptool | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/wasptool b/tools/wasptool index 339344e..30d020e 100755 --- a/tools/wasptool +++ b/tools/wasptool @@ -29,13 +29,27 @@ def sync(c): Sending a random print ensure the final export (of the prompt) does not accidentally match a previously issued prompt. """ + verbose = bool(c.logfile) tag = ''.join([random.choice(string.ascii_uppercase) for i in range(6)]) - c.send('\x03') - c.expect('>>> ') - c.sendline(f'print("{tag[:3]}""{tag[3:]}")') - c.expect(tag) - c.expect('>>> ') + + try: + if not verbose: + c.logfile = io.StringIO() + + c.send('\x03') + c.expect('>>> ') + c.sendline(f'print("{tag[:3]}""{tag[3:]}")') + c.expect(tag) + c.expect('>>> ') + + if not verbose: + c.logfile.close() + c.logfile = None + except pexpect.exceptions.EOF: + print("ERROR: Cannot sync with device") + print_log(c.logfile) + sys.exit(1) def unsync(c): """Set the watch running again. |
