From db9f7071f7638940cc598dfb82f119e75e7b1015 Mon Sep 17 00:00:00 2001 From: ethanholen-hpe Date: Wed, 11 Dec 2024 10:26:36 -0700 Subject: [PATCH] CRAYSAT-1947: fix sorting warnings in sat showrev (cherry picked from commit 179a57c7eb3bdfa2e0592a6a93c890536b34f768) --- CHANGELOG.md | 5 +++++ sat/cli/showrev/main.py | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 863ec1aa..d990ca91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.33.5] - 2024-12-11 + +### Fixed +- Fixed sorting warnings in `sat showrev` + ## [3.33.4] - 2024-12-11 ### Added diff --git a/sat/cli/showrev/main.py b/sat/cli/showrev/main.py index 6ea52135..e9d46715 100644 --- a/sat/cli/showrev/main.py +++ b/sat/cli/showrev/main.py @@ -67,15 +67,17 @@ def do_showrev(args): # The `showrev` command sets the default of `--sort-by` to None, so we can use that to # determine if the user explicitly set the value, and use a special default if not. if args.sort_by is None: - sort_by = ['product_name', 'product_version'] + product_sort_by = ['product_name', 'product_version'] + other_sort_by = 0 else: - sort_by = args.sort_by + product_sort_by = args.sort_by + other_sort_by = args.sort_by # report formatting reverse = args.reverse no_headings = get_config_value('format.no_headings') no_borders = get_config_value('format.no_borders') - def append_report(title, headings, data): + def append_report(title, headings, data, sort_by): """Create a new Report and add it to the list of reports. Args: @@ -84,6 +86,7 @@ def append_report(title, headings, data): of the Report data: A list of tuples where each element is a row to add to the new Report + sort_by: an item or list of items to sort the report by Returns: None. Modifies reports in place. @@ -103,7 +106,8 @@ def append_report(title, headings, data): append_report( 'System Revision Information', ['component', 'data'], - system.get_system_version(args.sitefile) + system.get_system_version(args.sitefile), + other_sort_by ) if args.release_files: @@ -115,14 +119,16 @@ def append_report(title, headings, data): append_report( 'Product Revision Information', product_headings, - product_data + product_data, + product_sort_by ) if args.local: append_report( 'Local Host Operating System', ['component', 'version'], - local.get_local_os_information() + local.get_local_os_information(), + other_sort_by ) if not reports: