Getting a unique hardware ID with Python -
i have process requires me identify different machines, , i'm not sure what's best way it. not want save id on text file or something, want generate hardware every time need (in case text id gets deleted or something)
i've checked uuid, , seems ok i'm not sure. i've taken @ uuid.getnode(), have 2 problems it:
one part says "if attempts obtain hardware address fail, choose random 48-bit number eighth bit set 1 recommended in rfc 4122", means may different unique on systems reason - there way identify time failed , generate else?
another part says: " “hardware address” means mac address of network interface, , on machine multiple network interfaces mac address of 1 of them may returned.", means if have 2 different network adapters, each call may 1 of them? that's not me.
if have better way of obtaining unique id machine, can generate each time , won't have worry deletion of or - i'd glad hear it. of attempts find have failed. thanks.
you 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 windows
import subprocess def get_id(): return subprocess.popen('dmidecode.exe -s system-uuid'.split())
cross-platform:
note: requires dmidecode 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())
Comments
Post a Comment