summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-06-19 10:51:03 +0200
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>2024-06-21 13:57:00 +0200
commitb7676b8e0e011e590fd22f505c66fa3946e8e38b (patch)
treef032884de4162ff9d919ad7b1eec0aa0559a9f61
parent94c72f097369eca6be604b2815fe13a1d5ca725b (diff)
downloadu-boot-b7676b8e0e011e590fd22f505c66fa3946e8e38b.tar.gz
u-boot-b7676b8e0e011e590fd22f505c66fa3946e8e38b.tar.bz2
u-boot-b7676b8e0e011e590fd22f505c66fa3946e8e38b.zip
scripts: sd_fusing: Add sfdisk error handling
Change-Id: I46519635e252de19a131a65bbd177eb9500b0138
-rwxr-xr-xscripts/tizen/sd_fusing.py14
1 files 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