From e924f344418a3738deabba66e4f6c1a96fa306c9 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Wed, 18 Mar 2026 17:10:46 +0100 Subject: [PATCH] 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 --- src/python/jw/pkg/App.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index 0c029607..8dca1be0 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -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: