Skip to content

Commit

Permalink
Make it impossible for blockdev calls to cause exception
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Oct 10, 2023
1 parent db5528d commit 3b1799f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ def __init__(self, option, device):
self.cmd = ["blockdev", option, device]

def __str__(self):
with subprocess.Popen(self.cmd, stdout=subprocess.PIPE) as proc:
output = proc.stdout.readline().strip().decode("utf-8")
try:
with subprocess.Popen(self.cmd, stdout=subprocess.PIPE) as proc:
output = proc.stdout.readline().strip().decode("utf-8")
except: # pylint: disable=bare-except
return f"could not gather output of {self.cmd}"

return f"output of {self.cmd}: {output}"


Expand Down

0 comments on commit 3b1799f

Please sign in to comment.