Skip to content

Commit

Permalink
Add exception handler for wmi module
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Jun 25, 2024
1 parent 13950a7 commit ac8e5df
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions osu/objects/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ac8e5df

Please sign in to comment.