From a6160e576347358db79071cf2e4ee5dc623ce7ec Mon Sep 17 00:00:00 2001 From: Stefan Hertrampf Date: Mon, 8 Apr 2024 12:10:19 +0200 Subject: [PATCH] nixos/test-driver: use function instead of var Use a proper function to enable serial log printing instead of setting class member variables directly. --- nixos/lib/test-driver/test_driver/driver.py | 4 ++-- nixos/lib/test-driver/test_driver/logger.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/lib/test-driver/test_driver/driver.py b/nixos/lib/test-driver/test_driver/driver.py index 7dfbfdcf1c2a..0650acb4d897 100644 --- a/nixos/lib/test-driver/test_driver/driver.py +++ b/nixos/lib/test-driver/test_driver/driver.py @@ -249,10 +249,10 @@ class Driver: ) def serial_stdout_on(self) -> None: - rootlog._print_serial_logs = True + rootlog.print_serial_logs(True) def serial_stdout_off(self) -> None: - rootlog._print_serial_logs = False + rootlog.print_serial_logs(False) def check_polling_conditions(self) -> None: for condition in self.polling_conditions: diff --git a/nixos/lib/test-driver/test_driver/logger.py b/nixos/lib/test-driver/test_driver/logger.py index 1b802f992f64..77a9b81c5946 100644 --- a/nixos/lib/test-driver/test_driver/logger.py +++ b/nixos/lib/test-driver/test_driver/logger.py @@ -24,6 +24,9 @@ class Logger: self._print_serial_logs = True + def print_serial_logs(self, enable: bool) -> None: + self._print_serial_logs = enable + @staticmethod def _eprint(*args: object, **kwargs: Any) -> None: print(*args, file=sys.stderr, **kwargs)