code format

This commit is contained in:
erpalma
2018-08-22 12:07:14 +02:00
parent d322c93699
commit 2e7646d824

View File

@@ -45,7 +45,7 @@ platform_info_bits = {
'number_of_additional_tdp_profiles': [33, 34],
'feature_programmable_temperature_target': [30, 30],
'feature_low_power_mode': [32, 32]
}
}
thermal_status_bits = {
'thermal_limit_status': [0, 0],
@@ -67,7 +67,7 @@ thermal_status_bits = {
'cpu_temp': [16, 22],
'temp_resolution': [27, 30],
'reading_valid': [31, 31],
}
}
def writemsr(msr, val):
@@ -123,14 +123,17 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False):
else:
raise e
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))
return (val & mask) >> from_bit
def is_on_battery():
with open(SYSFS_POWER_PATH) as f:
return not bool(int(f.read()))
def get_cpu_platform_info():
features_msr_value = readmsr(0xce, cpu=0)
cpu_platform_info = {}
@@ -302,8 +305,7 @@ def power_thread(config, regs, exit_event):
thermal_status = get_reset_thermal_status()
for index, core_thermal_status in enumerate(thermal_status):
for key, value in core_thermal_status.items():
print('[D] core {} thermal status: {} = {}'.format(
index, key.replace("_", " "), value))
print('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
# switch back to sysfs polling
if power['method'] == 'polling':
@@ -377,8 +379,7 @@ def main():
platform_info = get_cpu_platform_info()
if args.debug:
for key, value in platform_info.items():
print('[D] cpu platform info: {} = {}'.format(
key.replace("_", " "), value))
print('[D] cpu platform info: {} = {}'.format(key.replace("_", " "), value))
regs = calc_reg_values(platform_info, config)
if not config.getboolean('GENERAL', 'Enabled'):