From ac8e5df3d26d2f35fdd850cdbd5d8d58297ea410 Mon Sep 17 00:00:00 2001 From: Lekuru Date: Tue, 25 Jun 2024 04:18:46 +0200 Subject: [PATCH] Add exception handler for wmi module --- osu/objects/client.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu/objects/client.py b/osu/objects/client.py index 035f2a4..92523ea 100644 --- a/osu/objects/client.py +++ b/osu/objects/client.py @@ -111,11 +111,14 @@ def disk_signature(self) -> str: if platform.system() != "Windows": return hashlib.md5(b"unknown").hexdigest() - from wmi import WMI + try: + from wmi import WMI - # Get serial number of first item - for item in WMI().query("SELECT * FROM Win32_DiskDrive"): - return hashlib.md5(item.SerialNumber.encode()).hexdigest() + # Get serial number of first item + for item in WMI().query("SELECT * FROM Win32_DiskDrive"): + return hashlib.md5(item.SerialNumber.encode()).hexdigest() + except Exception: + pass # Fallback return hashlib.md5(b"unknown").hexdigest()