From b7676b8e0e011e590fd22f505c66fa3946e8e38b Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Wed, 19 Jun 2024 10:51:03 +0200 Subject: [PATCH] scripts: sd_fusing: Add sfdisk error handling Change-Id: I46519635e252de19a131a65bbd177eb9500b0138 --- scripts/tizen/sd_fusing.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index 1996250aa6..ff1ed742c3 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -15,7 +15,7 @@ import sys import tarfile import tempfile -__version__ = "1.1.3" +__version__ = "1.1.4" Format = False Device = "" @@ -728,8 +728,16 @@ def device_size(device): argv = ["sfdisk", "-s", device] logging.debug(" ".join(argv)) proc = subprocess.run(argv, - stdout=subprocess.PIPE) - size = int(proc.stdout.decode('utf-8').strip()) >> 10 + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout = proc.stdout.decode('utf-8') + try: + size = int(stdout.strip()) >> 10 + except ValueError: + stderr = proc.stderr.decode('utf-8') + logging.error(f"Unexpected sfdisk output:\n{stdout}\n{stderr}\n") + sys.exit(1) + logging.debug(f"{device} size {size}MiB") return size -- 2.34.1