mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Add user to homeassistant system health (#53902)
This commit is contained in:
parent
27848720a4
commit
3f2e18fe17
@ -4,6 +4,7 @@
|
||||
"arch": "CPU Architecture",
|
||||
"dev": "Development",
|
||||
"docker": "Docker",
|
||||
"user": "User",
|
||||
"hassio": "Supervisor",
|
||||
"installation_type": "Installation Type",
|
||||
"os_name": "Operating System Family",
|
||||
@ -14,4 +15,4 @@
|
||||
"virtualenv": "Virtual Environment"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ async def system_health_info(hass):
|
||||
"dev": info.get("dev"),
|
||||
"hassio": info.get("hassio"),
|
||||
"docker": info.get("docker"),
|
||||
"user": info.get("user"),
|
||||
"virtualenv": info.get("virtualenv"),
|
||||
"python_version": info.get("python_version"),
|
||||
"os_name": info.get("os_name"),
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""Helper to gather system info."""
|
||||
from __future__ import annotations
|
||||
|
||||
from getpass import getuser
|
||||
import os
|
||||
import platform
|
||||
from typing import Any
|
||||
@ -22,6 +23,7 @@ async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]:
|
||||
"virtualenv": is_virtual_env(),
|
||||
"python_version": platform.python_version(),
|
||||
"docker": False,
|
||||
"user": getuser(),
|
||||
"arch": platform.machine(),
|
||||
"timezone": str(hass.config.time_zone),
|
||||
"os_name": platform.system(),
|
||||
@ -37,7 +39,8 @@ async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]:
|
||||
|
||||
# Determine installation type on current data
|
||||
if info_object["docker"]:
|
||||
info_object["installation_type"] = "Home Assistant Container"
|
||||
if info_object["user"] == "root":
|
||||
info_object["installation_type"] = "Home Assistant Container"
|
||||
elif is_virtual_env():
|
||||
info_object["installation_type"] = "Home Assistant Core"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Tests for the system info helper."""
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.const import __version__ as current_version
|
||||
|
||||
@ -9,4 +10,20 @@ async def test_get_system_info(hass):
|
||||
info = await hass.helpers.system_info.async_get_system_info()
|
||||
assert isinstance(info, dict)
|
||||
assert info["version"] == current_version
|
||||
assert info["user"] is not None
|
||||
assert json.dumps(info) is not None
|
||||
|
||||
|
||||
async def test_container_installationtype(hass):
|
||||
"""Test container installation type."""
|
||||
with patch("platform.system", return_value="Linux"), patch(
|
||||
"os.path.isfile", return_value=True
|
||||
):
|
||||
info = await hass.helpers.system_info.async_get_system_info()
|
||||
assert info["installation_type"] == "Home Assistant Container"
|
||||
|
||||
with patch("platform.system", return_value="Linux"), patch(
|
||||
"os.path.isfile", return_value=True
|
||||
), patch("homeassistant.helpers.system_info.getuser", return_value="user"):
|
||||
info = await hass.helpers.system_info.async_get_system_info()
|
||||
assert info["installation_type"] == "Unknown"
|
||||
|
Loading…
x
Reference in New Issue
Block a user