From 8fb9166b8d9c33775d895a091c17269f0137efee Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:53:12 +0200 Subject: [PATCH] catch FileNotFoundError --- src/pycanape/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pycanape/utils.py b/src/pycanape/utils.py index 04a5f77..98154d1 100644 --- a/src/pycanape/utils.py +++ b/src/pycanape/utils.py @@ -54,7 +54,9 @@ def _kill_canape_processes() -> None: def get_canape_versions() -> List[CANapeVersion]: """Return a list of all CANape versions, that can be found in Windows Registry.""" versions: List[CANapeVersion] = [] - with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\VECTOR\\CANape") as key: + with contextlib.suppress(FileNotFoundError), winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\VECTOR\\CANape" + ) as key: _sub_key_count, value_count, _last_modified = winreg.QueryInfoKey(key) for idx in range(value_count): name, _data, _type = winreg.EnumValue(key, idx)