From e3b2890da7aae3f512a9b170e896384fe880db0d Mon Sep 17 00:00:00 2001 From: vikumarks Date: Fri, 10 Oct 2025 12:18:42 -0700 Subject: [PATCH] when json flag is set do not print other than json --- scripts/portstat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/portstat b/scripts/portstat index 56aae631fe..15d245f9f3 100755 --- a/scripts/portstat +++ b/scripts/portstat @@ -149,7 +149,7 @@ Examples: if os.path.isfile(cnstat_fqn_file): try: cnstat_cached_dict = json.load(open(cnstat_fqn_file, 'r')) - if not detail: + if not use_json and not detail: print("Last cached time was " + str(cnstat_cached_dict.get('time'))) portstat.cnstat_diff_print(cnstat_dict, cnstat_cached_dict, ratestat_dict, intf_list, use_json, print_all, errors_only, @@ -169,7 +169,8 @@ Examples: else: #wait for the specified time and then gather the new stats and output the difference. time.sleep(wait_time_in_seconds) - print("The rates are calculated within %s seconds period" % wait_time_in_seconds) + if not use_json: + print("The rates are calculated within %s seconds period" % wait_time_in_seconds) cnstat_new_dict, ratestat_new_dict = portstat.get_cnstat_dict() portstat.cnstat_diff_print(cnstat_new_dict, cnstat_dict, ratestat_new_dict, intf_list, use_json, print_all, errors_only,