Skip to content

Commit

Permalink
handle cases when losetup returns no output (empty)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Mar 26, 2024
1 parent b82e4fb commit d06d1cf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/offspot_demo/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ def get_loopdev() -> str:

def get_losetup() -> list[dict[str, str | int]]:
"""list of devices returned by losetup from, JSON output"""
return json.loads(
subprocess.run(
output = subprocess.run(
["/usr/bin/env", "losetup", "--json"],
check=True,
capture_output=True,
text=True,
env=get_environ(),
).stdout.strip()
)["loopdevices"]
if not output:
return []
return json.loads(output)["loopdevices"]


def is_loopdev_free(loop_dev: str):
Expand Down

0 comments on commit d06d1cf

Please sign in to comment.