Skip to content

Commit

Permalink
fix LGTM errors
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Sreenivasan <prabhu.sreenivasan@broadcom.com>
  • Loading branch information
Prabhu Sreenivasan authored and PrabhuSreenivasan committed Jan 28, 2021
1 parent 1774da7 commit 29cd2cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
8 changes: 2 additions & 6 deletions scripts/thresholdbreach
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3

############################################################################
#
Expand All @@ -7,10 +7,7 @@
############################################################################

import argparse
import getopt
import json
import sys
import swsssdk
from natsort import natsorted
from tabulate import tabulate
from swsssdk import ConfigDBConnector
Expand Down Expand Up @@ -75,7 +72,7 @@ class Thresholdbreach(object):
table.append((data['eventid'], data['buffer'], data['type'], data['port'], data['index'],
data['breach_value'], data['counter'], data['time-stamp']))

print tabulate(table, header, tablefmt='simple', stralign='right')
print(tabulate(table, header, tablefmt='simple', stralign='right'))
return

def clear_all_threshold_breach(self, count):
Expand All @@ -94,7 +91,6 @@ class Thresholdbreach(object):
def main():

parser = argparse.ArgumentParser(description='Display the queue/pg/buffer-pool threshold breaches',
version='1.0.0',
formatter_class=argparse.RawTextHelpFormatter,
epilog=""")
Examples:
Expand Down
31 changes: 14 additions & 17 deletions scripts/thresholdcfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

############################################################################
#
Expand All @@ -7,8 +7,6 @@
############################################################################

import argparse
import getopt
import json
import sys
import swsssdk
from swsssdk import ConfigDBConnector
Expand Down Expand Up @@ -61,7 +59,7 @@ class Thresholdcfg(object):
def get_queue_type(table_id):
queue_type = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_QUEUE_TYPE_MAP, table_id)
if queue_type is None:
print "Queue Type is not available!", table_id
print("Queue Type is not available!", table_id)
sys.exit(1)
elif queue_type == SAI_QUEUE_TYPE_MULTICAST:
return QUEUE_TYPE_MC
Expand All @@ -71,29 +69,29 @@ class Thresholdcfg(object):
elif queue_type == SAI_QUEUE_TYPE_ALL:
return QUEUE_TYPE_ALL
else:
print "Queue Type is invalid:", table_id, queue_type
print("Queue Type is invalid:", table_id, queue_type)
sys.exit(1)

def get_queue_port(table_id):
port_table_id = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_QUEUE_PORT_MAP, table_id)
if port_table_id is None:
print "Port is not available!", table_id
print("Port is not available!", table_id)
sys.exit(1)

return port_table_id

def get_pg_port(table_id):
port_table_id = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_PG_PORT_MAP, table_id)
if port_table_id is None:
print "Port is not available!", table_id
print("Port is not available!", table_id)
sys.exit(1)

return port_table_id

# Get all ports
self.counter_port_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_PORT_NAME_MAP)
if self.counter_port_name_map is None:
print "COUNTERS_PORT_NAME_MAP is empty!"
print("COUNTERS_PORT_NAME_MAP is empty!")
sys.exit(1)

self.port_uc_queues_map = {}
Expand All @@ -110,7 +108,7 @@ class Thresholdcfg(object):
# Get Queues for each port
counter_queue_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_QUEUE_NAME_MAP)
if counter_queue_name_map is None:
print "COUNTERS_QUEUE_NAME_MAP is empty!"
print("COUNTERS_QUEUE_NAME_MAP is empty!")
sys.exit(1)

for queue in counter_queue_name_map:
Expand All @@ -124,7 +122,7 @@ class Thresholdcfg(object):
# Get PGs for each port
counter_pg_name_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_PG_NAME_MAP)
if counter_pg_name_map is None:
print "COUNTERS_PG_NAME_MAP is empty!"
print("COUNTERS_PG_NAME_MAP is empty!")
sys.exit(1)

for pg in counter_pg_name_map:
Expand Down Expand Up @@ -172,15 +170,15 @@ class Thresholdcfg(object):
def get_queue_index(self, table_id):
queue_index = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_QUEUE_INDEX_MAP, table_id)
if queue_index is None:
print "Queue index is not available!", table_id
print("Queue index is not available!", table_id)
sys.exit(1)

return queue_index

def get_pg_index(self, table_id):
pg_index = self.counters_db.get(self.counters_db.COUNTERS_DB, COUNTERS_PG_INDEX_MAP, table_id)
if pg_index is None:
print "Priority group index is not available!", table_id
print("Priority group index is not available!", table_id)
sys.exit(1)

return pg_index
Expand Down Expand Up @@ -214,7 +212,7 @@ class Thresholdcfg(object):
table = []
buffer_pool_name_to_oid_map = self.counters_db.get_all(self.counters_db.COUNTERS_DB, COUNTERS_BUFFER_POOL_NAME_MAP)
if buffer_pool_name_to_oid_map is None:
print "Buffer pools are empty.Not created"
print("Buffer pools are empty.Not created")
return

for buf_pool,buf_oid in natsorted(buffer_pool_name_to_oid_map.items()):
Expand All @@ -224,7 +222,7 @@ class Thresholdcfg(object):
if data is None:
data = 0
table.append((buf_pool, data))
print tabulate(table, type["header"], tablefmt='simple', stralign='right')
print(tabulate(table, type["header"], tablefmt='simple', stralign='right'))
return

def get_print_cpu_queue_stat(self, table_prefix, type, th_type):
Expand All @@ -237,7 +235,7 @@ class Thresholdcfg(object):
if data is None:
data = 0
table.append((item, data))
print tabulate(table, type["header"], tablefmt='simple', stralign='right')
print(tabulate(table, type["header"], tablefmt='simple', stralign='right'))
return

def get_print_all_stat(self, table_prefix, type, th_type):
Expand All @@ -248,14 +246,13 @@ class Thresholdcfg(object):
type["obj_map"][port], type["idx_func"], type["th_name"], th_type)
table.append((port, data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7]))
print tabulate(table, type["header"], tablefmt='simple', stralign='right')
print(tabulate(table, type["header"], tablefmt='simple', stralign='right'))
return


def main():

parser = argparse.ArgumentParser(description='Display the queue/pg thresholds',
version='1.0.0',
formatter_class=argparse.RawTextHelpFormatter,
epilog="""
Examples:
Expand Down

0 comments on commit 29cd2cf

Please sign in to comment.