Getting a unique hardware ID with Python
You could use dmidecode
.
Linux:
import subprocess
def get_id():
return subprocess.Popen('hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.uuid'.split())
Windows:
NOTE: Requires dmidecode for Windows
import subprocess
def get_id():
return subprocess.Popen('dmidecode.exe -s system-uuid'.split())
Cross-platform:
NOTE: Requires dmidecode for Windows
import subprocess
import os
def get_id():
if 'nt' in os.name:
return subprocess.Popen('dmidecode.exe -s system-uuid'.split())
else:
return subprocess.Popen('hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.uuid'.split())
Please note that you can get the same UUID from Windows without installing any additional software with the following command:
C:\> wmic csproduct get uuid