From 4d4ccf4bde93b2f4f6f9783428d0c2739d37f93d Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 24 Jun 2024 10:35:34 -0500 Subject: [PATCH] SWDEV-446724 - Version command human readable output file format fix Signed-off-by: Maisam Arif Change-Id: I94de5b03355b503ade307f2a3881acd07266d6c7 [ROCm/amdsmi commit: 943c74b6ef87455ea454c19c205630b1afc3e83d] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 12 +++++++++--- projects/amdsmi/amdsmi_cli/amdsmi_logger.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 7ea9ae2573..16823c4b20 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -115,9 +115,15 @@ class AMDSMICommands(): self.logger.output['rocm_version'] = f'{rocm_version_str}' if self.logger.is_human_readable_format(): - print(f'AMDSMI Tool: {__version__} | '\ - f'AMDSMI Library version: {amdsmi_lib_version_str} | ' \ - f'ROCm version: {rocm_version_str}') + human_readable_output = f"AMDSMI Tool: {__version__} | " \ + f"AMDSMI Library version: {amdsmi_lib_version_str} | " \ + f"ROCm version: {rocm_version_str}" + # Custom human readable handling for version + if self.logger.destination == 'stdout': + print(human_readable_output) + else: + with self.logger.destination.open('a') as output_file: + output_file.write(human_readable_output + '\n') elif self.logger.is_json_format() or self.logger.is_csv_format(): self.logger.print_output() diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py index c0ffe5a8fb..b54d669897 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_logger.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_logger.py @@ -465,7 +465,7 @@ class AMDSMILogger(): self._print_tabular_output(multiple_device_enabled=multiple_device_enabled, watching_output=watching_output) else: self._print_human_readable_output(multiple_device_enabled=multiple_device_enabled, - watching_output=watching_output) + watching_output=watching_output) def _print_json_output(self, multiple_device_enabled=False, watching_output=False):