Skip to content

Commit 144fe7f

Browse files
committed
fix: windows serial number
1 parent 67ffd9a commit 144fe7f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

main.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,28 @@
1313
import os
1414
import subprocess
1515

16+
def get_serial_number_aux():
17+
os_type = sys.platform.lower()
18+
if "darwin" in os_type:
19+
command = "ioreg -l | grep IOPlatformSerialNumber"
20+
elif "win" in os_type:
21+
command = "wmic bios get serialnumber"
22+
elif "linux" in os_type:
23+
command = "dmidecode -s baseboard-serial-number"
24+
return os.popen(command).read().replace("\n", "").replace(" ", "").replace(" ", "")
1625

1726
def get_serial_number():
1827
try:
1928
system = platform.system()
2029
if system == 'Windows':
21-
return platform.win32_machineserial()
30+
return os.popen("wmic bios get serialnumber").read().replace("\n", "").replace(" ", "").replace(" ", "").replace("SerialNumber", "")
2231
elif system == 'Linux':
2332
if os.geteuid() != 0:
2433
print("Process needs to be root.")
2534
subprocess.call(['sudo', '-E', 'python3', *sys.argv])
2635
sys.exit()
2736
with open('/sys/class/dmi/id/product_serial') as file:
2837
return file.read().strip()
29-
elif system == 'Darwin':
30-
return platform.system_profiler().get('Hardware').get('Serial Number')
3138
else:
3239
return None
3340
except Exception as error:

0 commit comments

Comments
 (0)