Skip to content

Commit f035441

Browse files
committed
imgtool: Unify File not found error messages
Signed-off-by: Rustam Ismayilov <[email protected]> Change-Id: I67e614811c31e786efebc05b9264611d6bb17edb
1 parent 396f116 commit f035441

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

scripts/imgtool/dumpinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def dump_imginfo(imgfile, outfile=None, silent=False):
140140
with open(imgfile, "rb") as f:
141141
b = f.read()
142142
except FileNotFoundError:
143-
raise click.UsageError("Image file not found ({})".format(imgfile))
143+
raise click.UsageError(f"Image file not found: {imgfile}")
144144

145145
# Parsing the image header
146146
_header = struct.unpack('IIHHIIBBHI', b[:28])

scripts/imgtool/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def load(self, path):
238238
with open(path, 'rb') as f:
239239
self.payload = f.read()
240240
except FileNotFoundError:
241-
raise click.UsageError("Input file not found")
241+
raise click.UsageError(f"Image file not found: {path}")
242242

243243
# Add the image header if needed.
244244
if self.pad_header and self.header_size > 0:
@@ -647,7 +647,7 @@ def verify(imgfile, key):
647647
with open(imgfile, 'rb') as f:
648648
b = f.read()
649649
except FileNotFoundError:
650-
raise click.UsageError(f"Image file {imgfile} not found")
650+
raise click.UsageError(f"Image file not found: {imgfile}")
651651

652652
magic, _, header_size, _, img_size = struct.unpack('IIHHI', b[:16])
653653
version = struct.unpack('BBHI', b[20:28])

scripts/imgtool/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def load_key(keyfile):
9191
try:
9292
key = keys.load(keyfile)
9393
except FileNotFoundError as e:
94-
print("Key File Not Found in the path: " + keyfile)
94+
print(f"Key file not found: {keyfile}")
9595
raise e
9696
if key is not None:
9797
return key

scripts/tests/test_sign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ def test_sign_hex_file_not_exists(self, key_type, tmp_path_persistent):
12641264
],
12651265
)
12661266
assert result.exit_code != 0
1267-
assert "Input file not found" in result.output
1267+
assert "Image file not found" in result.output
12681268

12691269
@pytest.mark.parametrize("key_type", KEY_TYPES)
12701270
def test_sign_hex_padded(self, key_type, tmp_path_persistent):

scripts/tests/test_verify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_verify_key_not_exists(self, key_type, tmp_path_persistent):
109109
],
110110
)
111111
assert result.exit_code != 0
112-
assert "File Not Found" in result.stdout
112+
assert "Key file not found" in result.stdout
113113

114114
@pytest.mark.parametrize("key_type", KEY_TYPES)
115115
def test_verify_image_not_exists(self, key_type, tmp_path_persistent):
@@ -127,7 +127,7 @@ def test_verify_image_not_exists(self, key_type, tmp_path_persistent):
127127
],
128128
)
129129
assert result.exit_code != 0
130-
assert "File Not Found" in result.stdout
130+
assert "Image file not found" in result.stdout
131131

132132
@pytest.mark.parametrize("key_type", ("rsa-3072",))
133133
def test_verify_key_inv_magic(self, key_type, tmp_path_persistent):

0 commit comments

Comments
 (0)