From 2c91e7853c7f072c75ec999cfb78327bb5c76f39 Mon Sep 17 00:00:00 2001 From: Blake Blackshear Date: Sun, 12 Dec 2021 10:27:01 -0600 Subject: [PATCH] check for apex dir --- frigate/stats.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/frigate/stats.py b/frigate/stats.py index f83b2ae46..bc92907cd 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -31,25 +31,29 @@ def get_fs_type(path): bestMatch = part.mountpoint return fsType + def read_temperature(path): if os.path.isfile(path): with open(path) as f: - line=f.readline().strip() - return int(line)/1000 + line = f.readline().strip() + return int(line) / 1000 return None + def get_temperatures(): - temps={} + temps = {} # Get temperatures for all attached Corals - base="/sys/class/apex/" - for apex in os.listdir(base): - temp=read_temperature(os.path.join(base,apex,"temp")) - if temp is not None: - temps[apex]=temp + base = "/sys/class/apex/" + if os.path.isdir(base): + for apex in os.listdir(base): + temp = read_temperature(os.path.join(base, apex, "temp")) + if temp is not None: + temps[apex] = temp return temps + def stats_snapshot(stats_tracking): camera_metrics = stats_tracking["camera_metrics"] stats = {} @@ -80,7 +84,7 @@ def stats_snapshot(stats_tracking): "uptime": (int(time.time()) - stats_tracking["started"]), "version": VERSION, "storage": {}, - "temperatures" : get_temperatures() + "temperatures": get_temperatures(), } for path in [RECORD_DIR, CLIPS_DIR, CACHE_DIR, "/dev/shm"]: