pkg.App.os_release: Call cat /etc/os-release

Don't open and parse /etc/os-release with Python built-in functions.
Spawn "cat /etc/os-release" as a subprocess and capture the output
for parsing instead. The obvious advantage is that this also works
with a remote shell.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-18 17:10:46 +01:00
commit e924f34441

View file

@ -299,9 +299,9 @@ class App(Base):
@property
def os_release(self) -> str:
if self.__os_release is None:
os_release = '/etc/os-release'
with open(os_release, 'r') as file:
self.__os_release = file.read()
result = self.call_async(self.exec_context.run(['/usr/bin/cat', '/etc/os-release'], throw=True))
assert result.status == 0
self.__os_release = result.stdout.strip()
return self.__os_release
def os_release_field(self, key: str, throw: bool=False) -> str: