From f8404f3c1693ed08f56a6bde6f95d4e7ce472ca7 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 5 Feb 2019 20:31:16 -0700 Subject: [PATCH 1/5] Raise exception if temps above given threshold --- .bin/Scripts/functions/sensors.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/sensors.py b/.bin/Scripts/functions/sensors.py index 5d2f2fae..ab74b2e4 100644 --- a/.bin/Scripts/functions/sensors.py +++ b/.bin/Scripts/functions/sensors.py @@ -19,6 +19,11 @@ TEMP_LIMITS = { REGEX_COLORS = re.compile(r'\033\[\d+;?1?m') +# Error Classes +class ThermalError(Exception): + pass + + def clear_temps(sensor_data): """Clear saved temps but keep structure, returns dict.""" for _section, _adapters in sensor_data.items(): @@ -214,7 +219,7 @@ def save_average_temp(sensor_data, temp_label, seconds=10): _data[temp_label] = sum(_data['Temps']) / len(_data['Temps']) -def update_sensor_data(sensor_data): +def update_sensor_data(sensor_data, thermal_threshold=None): """Read sensors and update existing sensor_data, returns dict.""" json_data = get_raw_sensor_data() for _section, _adapters in sensor_data.items(): @@ -230,6 +235,11 @@ def update_sensor_data(sensor_data): # Dumb workound for Dell sensors with changing source names pass + # Check if thermal limit reached + if thermal_threshold and _section == 'CoreTemps': + if max(_data['Current'], _data['Max']) > thermal_threshold: + raise ThermalError('CoreTemps above threshold') + def join_columns(column1, column2, width=55): return '{:<{}}{}'.format( From 3c35a75c9258fc2c888864625fa371f50cff5a1e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 5 Feb 2019 21:06:40 -0700 Subject: [PATCH 2/5] Raise exception when temps >= limit --- .bin/Scripts/functions/sensors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/sensors.py b/.bin/Scripts/functions/sensors.py index ab74b2e4..221fcfc3 100644 --- a/.bin/Scripts/functions/sensors.py +++ b/.bin/Scripts/functions/sensors.py @@ -237,7 +237,7 @@ def update_sensor_data(sensor_data, thermal_threshold=None): # Check if thermal limit reached if thermal_threshold and _section == 'CoreTemps': - if max(_data['Current'], _data['Max']) > thermal_threshold: + if max(_data['Current'], _data['Max']) >= thermal_threshold: raise ThermalError('CoreTemps above threshold') From a28a754be1621b63e008a31bc0e7348b8fc0bdb1 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 5 Feb 2019 21:08:06 -0700 Subject: [PATCH 3/5] Added thermal limit logic to Prime95 test --- .bin/Scripts/functions/hw_diags.py | 24 +++++++++++++++++++----- .bin/Scripts/settings/main.py | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index b1ed5869..44a1c7f7 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -1262,6 +1262,7 @@ def run_mprime_test(state, test): test.update_status() update_progress_pane(state) test.sensor_data = get_sensor_data() + test.thermal_abort = False # Update tmux layout tmux_update_pane( @@ -1303,6 +1304,7 @@ def run_mprime_test(state, test): command=['hw-diags-prime95', global_vars['TmpDir']], working_dir=global_vars['TmpDir']) time_limit = int(MPRIME_LIMIT) * 60 + thermal_limit = int(THERMAL_LIMIT) try: for i in range(time_limit): clear_screen() @@ -1319,15 +1321,19 @@ def run_mprime_test(state, test): # Not using print wrappers to avoid flooding the log print(_status_str) print('{YELLOW}{msg}{CLEAR}'.format(msg=test.abort_msg, **COLORS)) - update_sensor_data(test.sensor_data) + update_sensor_data(test.sensor_data, thermal_limit) # Wait sleep(1) - except KeyboardInterrupt: - # Catch CTRL+C + except (KeyboardInterrupt, ThermalError) as err: + # CTRL+c pressed or thermal threshold reached test.aborted = True - test.update_status('Aborted') - print_warning('\nAborted.') + if isinstance(err, KeyboardInterrupt): + test.update_status('Aborted') + elif isinstance(err, ThermalError): + test.failed = True + test.thermal_abort = True + test.update_status('NS') update_progress_pane(state) # Restart live monitor @@ -1428,6 +1434,14 @@ def run_mprime_test(state, test): test.sensor_data, 'Idle', 'Max', 'Cooldown', core_only=True): test.report.append(' {}'.format(line)) + # Add abort message(s) + if test.aborted: + test.report.append( + ' {YELLOW}Aborted{CLEAR}'.format(**COLORS)) + if test.thermal_abort: + test.report.append( + ' {RED}CPU temps exceeded threshold{CLEAR}'.format(**COLORS)) + # Done update_progress_pane(state) diff --git a/.bin/Scripts/settings/main.py b/.bin/Scripts/settings/main.py index da83e830..e824f095 100644 --- a/.bin/Scripts/settings/main.py +++ b/.bin/Scripts/settings/main.py @@ -16,6 +16,7 @@ KIT_NAME_SHORT='WK' SUPPORT_MESSAGE='Please let 2Shirt know by opening an issue on GitHub' # Live Linux MPRIME_LIMIT='7' # of minutes to run Prime95 during hw-diags +THERMAL_LIMIT='95' # Prime95 abort temperature in Celsius ROOT_PASSWORD='Abracadabra' TECH_PASSWORD='Abracadabra' # Server IP addresses From dc6de9cab0cf8f110523db7c6272bced89cbd207 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 5 Feb 2019 21:25:28 -0700 Subject: [PATCH 4/5] Use consistent labels --- .bin/Scripts/functions/hw_diags.py | 8 ++++---- .bin/Scripts/functions/sensors.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 44a1c7f7..9ede016e 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -1325,12 +1325,12 @@ def run_mprime_test(state, test): # Wait sleep(1) - except (KeyboardInterrupt, ThermalError) as err: - # CTRL+c pressed or thermal threshold reached + except (KeyboardInterrupt, ThermalLimitReachedError) as err: + # CTRL+c pressed or thermal limit reached test.aborted = True if isinstance(err, KeyboardInterrupt): test.update_status('Aborted') - elif isinstance(err, ThermalError): + elif isinstance(err, ThermalLimitReachedError): test.failed = True test.thermal_abort = True test.update_status('NS') @@ -1440,7 +1440,7 @@ def run_mprime_test(state, test): ' {YELLOW}Aborted{CLEAR}'.format(**COLORS)) if test.thermal_abort: test.report.append( - ' {RED}CPU temps exceeded threshold{CLEAR}'.format(**COLORS)) + ' {RED}CPU reached temperature limit{CLEAR}'.format(**COLORS)) # Done update_progress_pane(state) diff --git a/.bin/Scripts/functions/sensors.py b/.bin/Scripts/functions/sensors.py index 221fcfc3..a7d742bb 100644 --- a/.bin/Scripts/functions/sensors.py +++ b/.bin/Scripts/functions/sensors.py @@ -20,7 +20,7 @@ REGEX_COLORS = re.compile(r'\033\[\d+;?1?m') # Error Classes -class ThermalError(Exception): +class ThermalLimitReachedError(Exception): pass @@ -219,7 +219,7 @@ def save_average_temp(sensor_data, temp_label, seconds=10): _data[temp_label] = sum(_data['Temps']) / len(_data['Temps']) -def update_sensor_data(sensor_data, thermal_threshold=None): +def update_sensor_data(sensor_data, thermal_limit=None): """Read sensors and update existing sensor_data, returns dict.""" json_data = get_raw_sensor_data() for _section, _adapters in sensor_data.items(): @@ -236,9 +236,9 @@ def update_sensor_data(sensor_data, thermal_threshold=None): pass # Check if thermal limit reached - if thermal_threshold and _section == 'CoreTemps': - if max(_data['Current'], _data['Max']) >= thermal_threshold: - raise ThermalError('CoreTemps above threshold') + if thermal_limit and _section == 'CoreTemps': + if max(_data['Current'], _data['Max']) >= thermal_limit: + raise ThermalLimitReachedError('CoreTemps reached limit') def join_columns(column1, column2, width=55): From 7132d971f6b309c1f781a42df19271acf29c0d7b Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Tue, 5 Feb 2019 21:26:27 -0700 Subject: [PATCH 5/5] Add temp limit to report --- .bin/Scripts/functions/hw_diags.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 9ede016e..3d6b5d03 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -1440,7 +1440,9 @@ def run_mprime_test(state, test): ' {YELLOW}Aborted{CLEAR}'.format(**COLORS)) if test.thermal_abort: test.report.append( - ' {RED}CPU reached temperature limit{CLEAR}'.format(**COLORS)) + ' {RED}CPU reached temperature limit of {temp}°C{CLEAR}'.format( + temp=THERMAL_LIMIT, + **COLORS)) # Done update_progress_pane(state)