UNVR-NAS/overlay/filesystem/usr/lib/python3/dist-packages/ubnthelpers.py
Chris Blake 9c08f287fc feat: add hdds/temps/version to display
* Write a mock ustorage tool to parse disk info for ulcmd
* Pass system temp info from unvr-fan-daemon to mock-ubnt-api via tmp file
* add mock ubnt-tools to make ulcmd happy and report our SN
* code cleanup and documentation update
2024-05-26 14:58:01 -05:00

21 lines
573 B
Python

#!/usr/bin/python3
from functools import lru_cache
"""
A handful of Ubiquiti Unifi device specific functions
"""
UBNTHAL_PATH = "/proc/ubnthal/system.info"
@lru_cache(None)
def get_ubnt_shortname() -> str:
try:
with open(UBNTHAL_PATH, "r") as f:
ubnthal_model = [i for i in f.readlines() if i.startswith("shortname=")][0]
return ubnthal_model.lstrip("shortname=").rstrip("\n")
except FileNotFoundError:
print(
f"Error: unable to open {UBNTHAL_PATH}; is the ubnthal kernel module loaded?!"
)
raise