Skip to content

Commit e156bea

Browse files
author
guoping.liu
committed
update system information for new project
1 parent 7264e2d commit e156bea

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

supervisor/http_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def _handle_system_info(self):
283283
# Safely get storage_space
284284
storage = system_info.storage_space if isinstance(system_info.storage_space, dict) else {"available": "", "total": ""}
285285
result = {
286-
"Device Model": getattr(system_info, "model", "Unknown"),
286+
"Model Name": getattr(system_info, "pretty_name", "Unknown"),
287+
"Model ID": getattr(system_info, "model", "Unknown"),
287288
"Device Name": getattr(system_info, "name", "Unknown"),
288289
"Version": getattr(system_info, "version", "Unknown"),
289290
"Build Number": getattr(system_info, "build_number", "Unknown"),
@@ -295,9 +296,9 @@ def _handle_system_info(self):
295296
else:
296297
# Default system info (unified style)
297298
result = {
298-
"Device Model": "LinuxBox",
299+
"Model Name": "LinuxBox",
299300
"Device Name": "3RHUB-Unknown",
300-
"Build Number": "1.0.0",
301+
"Build Number": "v1.0.0",
301302
"Zigbee Support": False,
302303
"Thread Support": False,
303304
"Memory": "",
@@ -329,7 +330,7 @@ def _handle_system_info(self):
329330
}
330331
selected = []
331332
for svc, val in service_map.items():
332-
if util.is_service_running(svc):
333+
if util.is_service_present(svc):
333334
selected.append(val)
334335
result["Services"] = ",".join(selected)
335336
except Exception:

supervisor/sysinfo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ class SystemInfo:
6464
def __init__(self):
6565
release_info = _get_t3r_release_info()
6666

67-
self.model = release_info.get("PRETTY_NAME", DEVICE_MODEL_NAME)
67+
self.model = release_info.get("MODLE", "3RLB01081MH")
68+
self.name = "3RHUB-XXXX"
69+
self.pretty_name = release_info.get("PRETTY_NAME", DEVICE_MODEL_NAME)
70+
6871
self.build_number = DEVICE_BUILD_NUMBER
6972
self.version = release_info.get("VERSION", "v0.0.1")
70-
self.name = "3RHUB-XXXX"
7173
self.support_zigbee=True
7274
self.support_thread=True # Fixed to always support thread
7375
self.mode = "homeassistant-core"

supervisor/utils/util.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,30 @@ def is_service_running(service_name):
115115
logging.error(f"Error checking if service {service_name} is running: {e}")
116116
return False
117117

118+
def is_service_present(service_name):
119+
"""
120+
Return True if the system has this service installed/known to systemd, regardless of running state.
121+
"""
122+
try:
123+
# systemctl status returns non-zero for inactive services, so do not check=True
124+
result = subprocess.run(["systemctl", "status", service_name], capture_output=True, text=True)
125+
# The output contains Loaded: loaded or could be not-found. Use that to determine presence.
126+
stdout = (result.stdout or "") + "\n" + (result.stderr or "")
127+
lowered = stdout.lower()
128+
if "loaded: loaded" in lowered:
129+
return True
130+
# Some distros show 'could not be found' or 'not-found' when unit does not exist
131+
if "not-found" in lowered or "could not be found" in lowered or "no such file" in lowered:
132+
return False
133+
# Fallback: try list-unit-files which enumerates installed unit files
134+
list_result = subprocess.run(["systemctl", "list-unit-files", service_name], capture_output=True, text=True)
135+
if list_result.returncode == 0 and service_name in (list_result.stdout or ""):
136+
return True
137+
return False
138+
except Exception as e:
139+
logging.error(f"Error checking if service {service_name} is present: {e}")
140+
return False
141+
118142
def is_service_enabled(service_name):
119143
try:
120144
result = subprocess.run(["systemctl", "is-enabled", service_name], capture_output=True, text=True)

0 commit comments

Comments
 (0)