rpymostat_common.unique_ids module

class rpymostat_common.unique_ids.SystemID[source]

Bases: object

Determine and retrieve a unique system ID for the hardware this is running on.

id_methods = ['raspberrypi_cpu', 'uuid_getnode']
id_string

Find/calculate and return the unique system ID string for the hardware this is running on.

Internally, this calls all method whose names are listed in id_methods, in order, and returns the value of the first one that returned something other than None.

Returns:unique, never-changing system ID
Return type:str
proc_cpuinfo_hw_re = <_sre.SRE_Pattern object>
proc_cpuinfo_rev_re = <_sre.SRE_Pattern object>
proc_cpuinfo_serial_re = <_sre.SRE_Pattern object>
random_fallback()[source]

Generate a host ID using a random UUID via Python’s uuid.uuid4(). Used as a fallback when the ID can’t be determined using any other method.

Returns:random UUID
Return type:str
raspberrypi_cpu()[source]

If this system is a Raspberry Pi, get its model and (CPU) serial number.

Thanks to: http://elinux.org/RPi_HardwareHistory#Board_Revision_History

Returns:RaspberryPi serial number
Return type:str
rpi_hardware = ['BCM2708', 'BCM2709']
rpi_revisions = {'0015': 'A+ 1.1 256MB (Embest)', '0014': 'Compute Module 1.0 512MB (Q2 2014 Embest)', '0013': 'B+ 1.2 512MB (Q1 2015)', '0012': 'A+ 1.1 256MB (Q4 2014 Sony)', '0011': 'Compute Module 1.0 512MB (Q2 2014 Sony)', '0010': 'B+ 1.0 512MB (Q3 2014 Sony)', '000d': 'B 2.0 512MB (Q4 2012 Egoman)', '000e': 'B 2.0 512MB (Q4 2012 Sony)', '000f': 'B 2.0 512MB (Q4 2012 Qisda)', 'a22082': '3 Model B 1.2 1024MB (Q1 2016)', 'Beta': 'B (Beta) ? 256MB (Q1 2012 Beta Board)', '900092': 'Zero 1.2 512MB (Q4 2015 Sony)', '900093': 'Zero 1.3 512MB (Q2 2016)', '0004': 'B 2.0 256MB (Q3 2012 Sony)', '0005': 'B 2.0 256MB (Q4 2012 Qisda)', '0006': 'B 2.0 256MB (Q4 2012 Egoman)', '0007': 'A 2.0 256MB (Q1 2013 Egoman)', '0002': 'B 1.0 256MB (Q1 2012)', '0003': 'B ECN0001 1.0 256MB (Q3 2012)', '0008': 'A 2.0 256MB (Q1 2013 Sony)', '0009': 'A 2.0 256MB (Q1 2013 Qisda)', 'a01041': '2 Model B 1.1 1GB (Q1 2015 Sony)', 'a02082': '3 Model B 1.2 1024MB (Q1 2016 Sony)', 'a21041': '2 Model B 1.1 1GB (Q1 2015 Embest)'}
uuid_getnode()[source]

Determine this system’s UUID via Python’s uuid.getnode() (slow) method.

Returns:hardware system ID from Python’s uuid.getnode()
Return type:str