Getting a unique hardware ID with Python

TzurEl

I have a process that requires me to identify different machines, and I'm not sure what's the best way to do it. I do not want to save that ID on a text file or something, but I want to generate it from hardware every time I need it (in case the text with the ID gets deleted or something)

I've checked UUID, and it seems ok but I'm not sure. I've taken a look at uuid.getNode(), but I have 2 problems with it:

  1. One part says "If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122", which means that I may get a different unique on some systems for some reason - is there a way to identify which time it failed and generate something else?

  2. another part says: " “Hardware address” means the MAC address of a network interface, and on a machine with multiple network interfaces the MAC address of any one of them may be returned.", which means if i have 2 different network adapters, each call I may get any one of them? that's not good for me.

If you have a better way of obtaining a unique ID for a machine, that I can generate each time and won't have to worry about deletion of it or something - I'd be glad to hear it. all of my attempts to find something have failed. Thanks.

Ciprum

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())

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting a unique hardware ID with Python

From Dev

Getting unique id in firebase

From Dev

Getting Unique Id for a list

From Dev

Getting Unique Id for a list

From Java

How to get unique device hardware id in Android?

From Dev

Getting error while generating the unique id using Python

From Dev

Getting unique id's Bank program java

From Dev

Getting NFC Unique ID within the oncreate method

From Dev

Getting unique id's Bank program java

From Dev

Getting unique ID from iPhone NFC

From Dev

How unique is Python's id()?

From Dev

Python transpose rows by unique id

From Dev

Getting unique tuples out of a python set

From Dev

getting unique date from python dataframe

From Dev

Getting unique tuples out of a python set

From Dev

getting unique date from python dataframe

From Dev

Getting my Post's ID to be random (but unique) string

From Dev

Getting the Unique Transaction ID seen by the customer from Express Checkout

From Dev

Getting Unique System ID on Mac using C#(Mono)

From Java

Getting first n unique elements from Python list

From Dev

Getting the unique names of a specific value from several keys of a dictionary in python

From Dev

Python getting unique pairs from multiple lists of different lengths

From Dev

Getting first n unique elements from Python list

From Dev

Getting the unique names of a specific value from several keys of a dictionary in python

From Dev

Python - How to flatten nested list getting unique values

From Dev

Python - getting post id on Facebook GraphAPI with Facepy

From Dev

Getting information on a machine's hardware in Linux

From Dev

Getting unique tuples in SQL

From Dev

getting unique items in an array

Related Related

HotTag

Archive