From 39f76448897c0788f074586dc3ace8fcd0070d67 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Thu, 15 Apr 2021 01:32:23 -0700 Subject: [PATCH] Don't fail on temp read/write --- src/py/bbctrl/MonitorTemp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/py/bbctrl/MonitorTemp.py b/src/py/bbctrl/MonitorTemp.py index 21b9746..6766d37 100644 --- a/src/py/bbctrl/MonitorTemp.py +++ b/src/py/bbctrl/MonitorTemp.py @@ -33,14 +33,19 @@ def read_temp(): path = '/sys/class/thermal/thermal_zone0/temp' if not os.path.exists(path): return 0 - with open(path, 'r') as f: - return round(int(f.read()) / 1000) + try: + with open(path, 'r') as f: + return round(int(f.read()) / 1000) + except: + return 0 def set_max_freq(freq): path = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq' if not os.path.exists(path): return - with open(path, 'w') as f: f.write('%d\n' % freq) + try: + with open(path, 'w') as f: f.write('%d\n' % freq) + except: pass class MonitorTemp(object): -- 2.27.0