From: Mateusz Majewski Date: Fri, 7 Jun 2024 10:44:44 +0000 (+0200) Subject: scripts: sd_fusing: handle lsblk errors better X-Git-Tag: accepted/tizen/unified/20240614.085106~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3184ca768e390fb7f33c81516a12da2b6fcb66a7;p=platform%2Fkernel%2Fu-boot.git scripts: sd_fusing: handle lsblk errors better This makes the error handling a bit more consistent with the rest of the script by logging an error and doing a sys.exit(1). Returning an error by returning None would mean that it would need to be handled elsewhere. However this does not happen, resulting in a confusing runtime error TypeError: can only concatenate str (not "NoneType") to str as well as warnings in some editors. Change-Id: I6b3f382e93846c3165d1a8221e2faf7dbf295a86 --- diff --git a/scripts/tizen/sd_fusing.py b/scripts/tizen/sd_fusing.py index ef0e754896..2513bdc078 100755 --- a/scripts/tizen/sd_fusing.py +++ b/scripts/tizen/sd_fusing.py @@ -975,24 +975,29 @@ def get_partition_device(device, idx): stdout=subprocess.PIPE) if proc.returncode != 0: logging.error("lsblk has failed") - return None + sys.exit(1) part_re = re.compile(f"^part\s+(.*[^0-9]{idx})$") for l in proc.stdout.decode('utf-8').splitlines(): match = part_re.match(l) if match: return match[1] - return None + logging.error("device entry not found") + sys.exit(1) def get_device_kname(device): argv = ['lsblk', device, '-o', 'TYPE,KNAME'] logging.debug(" ".join(argv)) proc = subprocess.run(argv, stdout=subprocess.PIPE) + if proc.returncode != 0: + logging.error("lsblk has failed") + sys.exit(1) for l in proc.stdout.decode('utf-8').splitlines(): match = re.search(f"^(disk|loop)\s+(.*)", l) if match: return match[2] - return None + logging.error("kname entry not found") + sys.exit(1) def do_fuse_file(f, name, target): indexes = target.get_partition_index_list(name)