forked from dhague/vpower
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstants.py
27 lines (23 loc) · 795 Bytes
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import platform
SPEED_DEVICE_TYPE = 0x7B
CADENCE_DEVICE_TYPE = 0x7A
SPEED_CADENCE_DEVICE_TYPE = 0x79
POWER_DEVICE_TYPE = 0x0B
# Get the serial number of Raspberry Pi or PC CPU (Windows)
def getserial():
cpuserial = "0000000000000000"
try:
if platform.system() == 'Windows':
# Extract serial from wmic command
from subprocess import check_output
cpuserial = check_output('wmic cpu get ProcessorId').decode().split('\n')[1].strip()
else:
# Extract serial from cpuinfo file
f = open('/proc/cpuinfo', 'r')
for line in f:
if line[0:6] == 'Serial':
cpuserial = line[10:26]
f.close()
except:
cpuserial = "ERROR000000000"
return cpuserial