code format
This commit is contained in:
@@ -123,14 +123,17 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False):
|
|||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def get_value_for_bits(val, from_bit=0, to_bit=63):
|
def get_value_for_bits(val, from_bit=0, to_bit=63):
|
||||||
mask = sum(2**x for x in range(from_bit, to_bit + 1))
|
mask = sum(2**x for x in range(from_bit, to_bit + 1))
|
||||||
return (val & mask) >> from_bit
|
return (val & mask) >> from_bit
|
||||||
|
|
||||||
|
|
||||||
def is_on_battery():
|
def is_on_battery():
|
||||||
with open(SYSFS_POWER_PATH) as f:
|
with open(SYSFS_POWER_PATH) as f:
|
||||||
return not bool(int(f.read()))
|
return not bool(int(f.read()))
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_platform_info():
|
def get_cpu_platform_info():
|
||||||
features_msr_value = readmsr(0xce, cpu=0)
|
features_msr_value = readmsr(0xce, cpu=0)
|
||||||
cpu_platform_info = {}
|
cpu_platform_info = {}
|
||||||
@@ -302,8 +305,7 @@ def power_thread(config, regs, exit_event):
|
|||||||
thermal_status = get_reset_thermal_status()
|
thermal_status = get_reset_thermal_status()
|
||||||
for index, core_thermal_status in enumerate(thermal_status):
|
for index, core_thermal_status in enumerate(thermal_status):
|
||||||
for key, value in core_thermal_status.items():
|
for key, value in core_thermal_status.items():
|
||||||
print('[D] core {} thermal status: {} = {}'.format(
|
print('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
|
||||||
index, key.replace("_", " "), value))
|
|
||||||
|
|
||||||
# switch back to sysfs polling
|
# switch back to sysfs polling
|
||||||
if power['method'] == 'polling':
|
if power['method'] == 'polling':
|
||||||
@@ -377,8 +379,7 @@ def main():
|
|||||||
platform_info = get_cpu_platform_info()
|
platform_info = get_cpu_platform_info()
|
||||||
if args.debug:
|
if args.debug:
|
||||||
for key, value in platform_info.items():
|
for key, value in platform_info.items():
|
||||||
print('[D] cpu platform info: {} = {}'.format(
|
print('[D] cpu platform info: {} = {}'.format(key.replace("_", " "), value))
|
||||||
key.replace("_", " "), value))
|
|
||||||
regs = calc_reg_values(platform_info, config)
|
regs = calc_reg_values(platform_info, config)
|
||||||
|
|
||||||
if not config.getboolean('GENERAL', 'Enabled'):
|
if not config.getboolean('GENERAL', 'Enabled'):
|
||||||
|
|||||||
Reference in New Issue
Block a user