Skip to content

Commit 1886121

Browse files
committed
Be more robust when listing keys
Currently the program terminates with a JSONDecodeError when the keystore directory contains files that are not valid keyfiles. However, there are some valid reasons why a keystore directory may contain other files, and so we can just skip those.
1 parent d63a425 commit 1886121

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

aut/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,10 @@ def address_keyfile_dict(keystore_dir: str) -> Dict[ChecksumAddress, str]:
334334
keyfile_list = os.listdir(keystore_dir)
335335
for fn in keyfile_list:
336336
keyfile_path = keystore_dir + "/" + fn
337-
keyfile = load_keyfile(keyfile_path)
337+
try:
338+
keyfile = load_keyfile(keyfile_path)
339+
except json.JSONDecodeError:
340+
continue
338341
addr_lower = keyfile["address"]
339342
addr_keyfile_dict[Web3.to_checksum_address("0x" + addr_lower)] = keyfile_path
340343

0 commit comments

Comments
 (0)