Don't fail on temp read/write
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 15 Apr 2021 08:32:23 +0000 (01:32 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Thu, 15 Apr 2021 08:32:23 +0000 (01:32 -0700)
src/py/bbctrl/MonitorTemp.py

index 21b97468a8297e25320b9065e087ac43765dc0d5..6766d37fc84c7b618bc66596e20b20690f828d54 100644 (file)
@@ -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):