From cbb068ccac4564df1e407fa384ae5a4e9f8debd4 Mon Sep 17 00:00:00 2001 From: Ori Messinger Date: Mon, 18 Jul 2022 03:34:19 -0400 Subject: [PATCH] ROCm SMI CLI: Force RETCODE to 0 by Default The purpose of this patch is to set RETCODE equal to 0 by default unless an appropriate '--loglevel LEVEL' has been set. To allow a non-zero RETCODE value, you must use any loglevel that is not 'warning' or 'None' (default). You can set the loglevel in the CLI with: --loglevel Signed-off-by: Ori Messinger Change-Id: I9484a750206a3f464c59952304e72c59c3d12465 --- python_smi_tools/rocm_smi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python_smi_tools/rocm_smi.py b/python_smi_tools/rocm_smi.py index 084a9f7601..c3c9142cb3 100755 --- a/python_smi_tools/rocm_smi.py +++ b/python_smi_tools/rocm_smi.py @@ -3281,6 +3281,12 @@ if __name__ == '__main__': if args.save: save(deviceList, args.save) + if RETCODE and not PRINT_JSON: + logging.debug(' \t\t One or more commands failed.') + # Set RETCODE value to 0, unless loglevel is None or 'warning' (default) + if args.loglevel is None or getattr(logging, args.loglevel.upper(), logging.WARNING) == logging.WARNING: + RETCODE = 0 + if PRINT_JSON: # Check that we have some actual data to print, instead of the # empty list that we initialized above @@ -3308,8 +3314,6 @@ if __name__ == '__main__': devCsv = formatCsv(deviceList) print(devCsv) - if RETCODE and not PRINT_JSON: - logging.debug(' \t\t One or more commands failed.') printLogSpacer(footerString) rsmi_ret_ok(rocmsmi.rsmi_shut_down())