From: Mateusz Moscicki Date: Wed, 19 Jun 2024 08:51:03 +0000 (+0200) Subject: scripts: sd_fusing: Add sfdisk error handling X-Git-Tag: accepted/tizen/unified/20241126.175211~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a0121f90ae095b0cef60f14843099f62b32985d;p=platform%2Fkernel%2Fu-boot.git scripts: sd_fusing: Add sfdisk error handling Change-Id: I46519635e252de19a131a65bbd177eb9500b0138 --- 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