Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pcieutil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def load_platform_pcieutil():
from sonic_platform.pcie import Pcie
platform_pcieutil = Pcie(platform_path)
except ImportError as e:
log.log_warning("Failed to load platform Pcie module. Error : {}, fallback to load Pcie common utility.".format(str(e)), True)
log.log_warning("Failed to load platform Pcie module. Warning : {}, fallback to load Pcie common utility.".format(str(e)))
try:
from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil
platform_pcieutil = PcieUtil(platform_path)
Expand Down
28 changes: 14 additions & 14 deletions scripts/portstat
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ class Portstat(object):
format_number_with_comma(data.tx_err),
format_number_with_comma(data.tx_drop),
format_number_with_comma(data.tx_ovr)))

if use_json:
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if multi_asic.is_multi_asic() or device_info.is_chassis():
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
if table:
if use_json:
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")

def cnstat_intf_diff_print(self, cnstat_new_dict, cnstat_old_dict, intf_list):
"""
Expand Down Expand Up @@ -522,13 +522,13 @@ class Portstat(object):
format_number_with_comma(cntr.tx_err),
format_number_with_comma(cntr.tx_drop),
format_number_with_comma(cntr.tx_ovr)))

if use_json:
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if multi_asic.is_multi_asic() or device_info.is_chassis():
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")
if table:
if use_json:
print(table_as_json(table, header))
else:
print(tabulate(table, header, tablefmt='simple', stralign='right'))
if multi_asic.is_multi_asic() or device_info.is_chassis() and not use_json:
print("\nReminder: Please execute 'show interface counters -d all' to include internal links\n")

def main():
parser = argparse.ArgumentParser(description='Display the ports state and counters',
Expand Down
13 changes: 13 additions & 0 deletions tests/pcieutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from unittest import mock

from click.testing import CliRunner
from io import StringIO

test_path = os.path.dirname(os.path.abspath(__file__))
modules_path = os.path.dirname(test_path)
Expand Down Expand Up @@ -156,6 +157,8 @@
+---------------------+-----------+
"""

pcieutil_load_module_warning_msg = "Failed to load platform Pcie module. Warning : No module named 'sonic_platform.pcie', fallback to load Pcie common utility."

class TestPcieUtil(object):
@classmethod
def setup_class(cls):
Expand Down Expand Up @@ -199,6 +202,16 @@ def test_aer_option_device(self):
result = runner.invoke(pcieutil.cli.commands["pcie-aer"].commands["correctable"], ["-d", "0:1.0"])
assert result.output == pcieutil_pcie_aer_correctable_dev_output

def test_load_pcie_module_warning(self):
stdout = sys.stdout
sys.stdout = result = StringIO()
try:
pcieutil.load_platform_pcieutil()
except ImportError:
pass
sys.stdout = stdout
assert pcieutil_load_module_warning_msg not in result.getvalue()

@classmethod
def teardown_class(cls):
print("TEARDOWN")
Expand Down