Skip to content

Commit

Permalink
check for apex dir
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeblackshear authored and NickM-27 committed Feb 20, 2022
1 parent 21c6056 commit 2994811
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions frigate/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,25 @@ 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

Expand Down

0 comments on commit 2994811

Please sign in to comment.