From 5c903df55fac449baae1e9cc23b04f6beeb55364 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Mon, 2 Oct 2023 21:01:23 +1100 Subject: Simplify SysCommand decoding (#2121) --- archinstall/lib/general.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'archinstall/lib/general.py') diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 71981fb6..3697cf2d 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -430,10 +430,15 @@ class SysCommand: return True - def decode(self, *args, **kwargs) -> Optional[str]: - if self.session: - return self.session._trace_log.decode(*args, **kwargs) - return None + def decode(self, encoding: str = 'utf-8', errors='backslashreplace', strip: bool = True) -> str: + if not self.session: + raise ValueError('No session available to decode') + + val = self.session._trace_log.decode(encoding, errors=errors) + + if strip: + return val.strip() + return val @property def exit_code(self) -> Optional[int]: -- cgit v1.2.3-70-g09d2