Skip to content

Commit 1dc3c51

Browse files
committed
fix: serial number not working on linux
1 parent 6816c53 commit 1dc3c51

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111
import json
1212
import sys
1313
import platform
14+
import os
15+
import subprocess
1416

1517
def get_serial_number():
1618
try:
1719
system = platform.system()
20+
print(system)
1821
if system == 'Windows':
1922
return platform.win32_machineserial()
2023
elif system == 'Linux':
24+
if os.geteuid() != 0:
25+
print("Process needs to be root.")
26+
subprocess.call(['sudo','-E', 'python3', *sys.argv])
27+
sys.exit()
2128
with open('/sys/class/dmi/id/product_serial') as f:
2229
return f.read().strip()
2330
elif system == 'Darwin':

0 commit comments

Comments
 (0)