From f684dd3ec4a63a4218738ffb927e43e782bdec50 Mon Sep 17 00:00:00 2001 From: DEvil0000 Date: Mon, 6 Aug 2018 09:51:50 +0200 Subject: [PATCH] don't crash on old config without the option --- lenovo_fix.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lenovo_fix.py b/lenovo_fix.py index 4df04d5..55ca96f 100755 --- a/lenovo_fix.py +++ b/lenovo_fix.py @@ -139,9 +139,12 @@ def calc_reg_values(config): TW2 << 49) # cTDP - c_tdp_target_value = int(config.getfloat(power_source, 'cTDP')) - valid_c_tdp_target_value = valid_trip_temp = min(C_TDP_RANGE[1], max(C_TDP_RANGE[0], c_tdp_target_value)) - regs[power_source]['MSR_CONFIG_TDP_CONTROL'] = valid_c_tdp_target_value + try: + c_tdp_target_value = int(config.getfloat(power_source, 'cTDP')) + valid_c_tdp_target_value = valid_trip_temp = min(C_TDP_RANGE[1], max(C_TDP_RANGE[0], c_tdp_target_value)) + regs[power_source]['MSR_CONFIG_TDP_CONTROL'] = valid_c_tdp_target_value + except configparser.NoOptionError: + pass return regs