check for apex dir

This commit is contained in:
Blake Blackshear 2021-12-12 10:27:01 -06:00
parent 1e7f196e5c
commit 2c91e7853c

View File

@ -31,25 +31,29 @@ def get_fs_type(path):
bestMatch = part.mountpoint bestMatch = part.mountpoint
return fsType return fsType
def read_temperature(path): def read_temperature(path):
if os.path.isfile(path): if os.path.isfile(path):
with open(path) as f: with open(path) as f:
line=f.readline().strip() line = f.readline().strip()
return int(line)/1000 return int(line) / 1000
return None return None
def get_temperatures(): def get_temperatures():
temps={} temps = {}
# Get temperatures for all attached Corals # Get temperatures for all attached Corals
base="/sys/class/apex/" base = "/sys/class/apex/"
if os.path.isdir(base):
for apex in os.listdir(base): for apex in os.listdir(base):
temp=read_temperature(os.path.join(base,apex,"temp")) temp = read_temperature(os.path.join(base, apex, "temp"))
if temp is not None: if temp is not None:
temps[apex]=temp temps[apex] = temp
return temps return temps
def stats_snapshot(stats_tracking): def stats_snapshot(stats_tracking):
camera_metrics = stats_tracking["camera_metrics"] camera_metrics = stats_tracking["camera_metrics"]
stats = {} stats = {}
@ -80,7 +84,7 @@ def stats_snapshot(stats_tracking):
"uptime": (int(time.time()) - stats_tracking["started"]), "uptime": (int(time.time()) - stats_tracking["started"]),
"version": VERSION, "version": VERSION,
"storage": {}, "storage": {},
"temperatures" : get_temperatures() "temperatures": get_temperatures(),
} }
for path in [RECORD_DIR, CLIPS_DIR, CACHE_DIR, "/dev/shm"]: for path in [RECORD_DIR, CLIPS_DIR, CACHE_DIR, "/dev/shm"]: