Fixes for demo
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 31 Jan 2021 07:14:55 +0000 (23:14 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 31 Jan 2021 07:14:55 +0000 (23:14 -0800)
src/py/bbctrl/MonitorTemp.py

index 41abfbcddeee1de7d4e35bf9187c7a7d7ec74bd0..f2987f6f927d4c35276612e85b05515f7bc2b5e5 100644 (file)
 ################################################################################
 
 import time
+import os
 
 
 def read_temp():
-    with open('/sys/class/thermal/thermal_zone0/temp', 'r') as f:
+    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)
 
 
 def set_max_freq(freq):
-    filename = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
-    with open(filename, 'w') as f: f.write('%d\n' % 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)
 
 
 class MonitorTemp(object):