mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-24 09:13:37 +02:00
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:
parent
df40af9fc3
commit
e924f34441
1 changed files with 3 additions and 3 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue