Skip to content

Commit

Permalink
machine: u-boot: Proper exception when retcode parsing fails
Browse files Browse the repository at this point in the history
Similar to commit b10aceb ("machine: linux: Proper exception when
retcode parsing fails"), improve the exception that is thrown when
parsing of a command's return code fails.

Signed-off-by: Rahix <[email protected]>
  • Loading branch information
Rahix committed Feb 16, 2024
1 parent b10aceb commit d078f32
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tbot/machine/board/uboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,13 @@ def exec(self, *args: ArgTypes) -> typing.Tuple[int, str]:
ev.data["stdout"] = out

self.ch.sendline("echo $?", read_back=True)
retcode = self.ch.read_until_prompt()
retcode_str = self.ch.read_until_prompt()
try:
retcode = int(retcode_str)
except ValueError:
raise tbot.error.InvalidRetcodeError(self, retcode_str) from None

return (int(retcode), out)
return (retcode, out)

def exec0(self, *args: ArgTypes) -> str:
"""
Expand Down

0 comments on commit d078f32

Please sign in to comment.