Fix a number of LGTM alerts (#5952)

Fix 259 alerts reported by the LGTM tool:

- 245 for Unused import
- 7 for Testing equality to None
- 5 for Duplicate key in dict literal
- 1 for Module is imported more than once
- 1 for Unused local variable
This commit is contained in:
Joe LeVeque 2020-11-20 10:58:48 -08:00 committed by GitHub
parent 461e43649b
commit 23247514f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 114 additions and 322 deletions

View File

@ -186,7 +186,7 @@ class SfpUtil(SfpUtilBase):
phy_port_dict = {} phy_port_dict = {}
status = True status = True
if self.db_sel == None: if self.db_sel is None:
from swsscommon import swsscommon from swsscommon import swsscommon
self.state_db = swsscommon.DBConnector("STATE_DB", self.state_db = swsscommon.DBConnector("STATE_DB",
REDIS_TIMEOUT_USECS, REDIS_TIMEOUT_USECS,

View File

@ -57,7 +57,7 @@ def generate_checksum(checksum_files):
def main(): def main():
config_files = sorted(get_config_files(CONFIG_FILES)) config_files = sorted(get_config_files(CONFIG_FILES))
checksum = generate_checksum(config_files) checksum = generate_checksum(config_files)
if checksum == None: if checksum is None:
exit(1) exit(1)
with open(OUTPUT_FILE, 'w') as output: with open(OUTPUT_FILE, 'w') as output:

View File

@ -219,7 +219,6 @@ class Handler(FileSystemEventHandler):
def upload_file(fname, fpath, coref): def upload_file(fname, fpath, coref):
daemonname = fname.split(".")[0] daemonname = fname.split(".")[0]
i = 0 i = 0
fail_msg = ""
while True: while True:
try: try:

View File

@ -20,19 +20,13 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time import time
import traceback
import commands import commands
from tabulate import tabulate
from as4630_54pe.fanutil import FanUtil from as4630_54pe.fanutil import FanUtil
from as4630_54pe.thermalutil import ThermalUtil from as4630_54pe.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,19 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -29,13 +29,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as4630_54pe' PROJECT_NAME = 'as4630_54pe'
version = '0.0.1' version = '0.0.1'
@ -54,7 +53,6 @@ hwmon_types = {'led': ['diag','fan','loc','psu1','psu2'],
'fan3': ['fan'], 'fan3': ['fan'],
'fan4': ['fan'], 'fan4': ['fan'],
'fan5': ['fan'], 'fan5': ['fan'],
'fan5': ['fan'],
} }
hwmon_nodes = {'led': ['brightness'] , hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'], 'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],

View File

@ -23,18 +23,11 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as5712_54x.fanutil import FanUtil from as5712_54x.fanutil import FanUtil
from as5712_54x.thermalutil import ThermalUtil from as5712_54x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -31,11 +31,11 @@ command:
import os import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as5712_54x' PROJECT_NAME = 'as5712_54x'
version = '0.2.0' version = '0.2.0'
@ -546,7 +546,7 @@ def cpld_path_of_port(port_index):
def get_path_sfp_tx_dis(port_index): def get_path_sfp_tx_dis(port_index):
cpld_p = cpld_path_of_port(port_index) cpld_p = cpld_path_of_port(port_index)
if cpld_p == None: if cpld_p is None:
return False, '' return False, ''
else: else:
dev = cpld_p+"module_tx_disable_"+str(port_index) dev = cpld_p+"module_tx_disable_"+str(port_index)
@ -554,7 +554,7 @@ def get_path_sfp_tx_dis(port_index):
def get_path_sfp_presence(port_index): def get_path_sfp_presence(port_index):
cpld_p = cpld_path_of_port(port_index) cpld_p = cpld_path_of_port(port_index)
if cpld_p == None: if cpld_p is None:
return False, '' return False, ''
else: else:
dev = cpld_p+"module_present_"+str(port_index) dev = cpld_p+"module_present_"+str(port_index)

View File

@ -23,19 +23,13 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as5812_54t.fanutil import FanUtil from as5812_54t.fanutil import FanUtil
from as5812_54t.thermalutil import ThermalUtil from as5812_54t.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -23,19 +23,13 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as5812_54x.fanutil import FanUtil from as5812_54x.fanutil import FanUtil
from as5812_54x.thermalutil import ThermalUtil from as5812_54x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -31,11 +31,11 @@ command:
import os import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as5812_54x' PROJECT_NAME = 'as5812_54x'
version = '0.2.0' version = '0.2.0'
@ -546,7 +546,7 @@ def cpld_path_of_port(port_index):
def get_path_sfp_tx_dis(port_index): def get_path_sfp_tx_dis(port_index):
cpld_p = cpld_path_of_port(port_index) cpld_p = cpld_path_of_port(port_index)
if cpld_p == None: if cpld_p is None:
return False, '' return False, ''
else: else:
dev = cpld_p+"module_tx_disable_"+str(port_index) dev = cpld_p+"module_tx_disable_"+str(port_index)
@ -554,7 +554,7 @@ def get_path_sfp_tx_dis(port_index):
def get_path_sfp_presence(port_index): def get_path_sfp_presence(port_index):
cpld_p = cpld_path_of_port(port_index) cpld_p = cpld_path_of_port(port_index)
if cpld_p == None: if cpld_p is None:
return False, '' return False, ''
else: else:
dev = cpld_p+"module_present_"+str(port_index) dev = cpld_p+"module_present_"+str(port_index)

View File

@ -25,18 +25,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as5835_54t.fanutil import FanUtil from as5835_54t.fanutil import FanUtil
from as5835_54t.thermalutil import ThermalUtil from as5835_54t.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -24,18 +24,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as5835_54x.fanutil import FanUtil from as5835_54x.fanutil import FanUtil
from as5835_54x.thermalutil import ThermalUtil from as5835_54x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -24,17 +24,11 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as6712_32x.fanutil import FanUtil from as6712_32x.fanutil import FanUtil
from as6712_32x.thermalutil import ThermalUtil from as6712_32x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -37,13 +37,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as6712_32x' PROJECT_NAME = 'as6712_32x'
version = '0.2.0' version = '0.2.0'

View File

@ -24,18 +24,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as7312_54x.fanutil import FanUtil from as7312_54x.fanutil import FanUtil
from as7312_54x.thermalutil import ThermalUtil from as7312_54x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -24,18 +24,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as7312_54xs.fanutil import FanUtil from as7312_54xs.fanutil import FanUtil
from as7312_54xs.thermalutil import ThermalUtil from as7312_54xs.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -24,18 +24,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as7315_27xb.fanutil import FanUtil from as7315_27xb.fanutil import FanUtil
from as7315_27xb.thermalutil import ThermalUtil from as7315_27xb.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -24,17 +24,12 @@
try: try:
import os import os
import sys, getopt import getopt
import subprocess import sys
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as7326_56x.fanutil import FanUtil from as7326_56x.fanutil import FanUtil
from as7326_56x.thermalutil import ThermalUtil from as7326_56x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,19 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -39,13 +39,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -23,17 +23,11 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as7716_32x.fanutil import FanUtil from as7716_32x.fanutil import FanUtil
from as7716_32x.thermalutil import ThermalUtil from as7716_32x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as7716_32x' PROJECT_NAME = 'as7716_32x'
version = '0.0.1' version = '0.0.1'
@ -55,7 +54,6 @@ hwmon_types = {'led': ['diag','fan','loc','psu1','psu2'],
'fan3': ['fan'], 'fan3': ['fan'],
'fan4': ['fan'], 'fan4': ['fan'],
'fan5': ['fan'], 'fan5': ['fan'],
'fan5': ['fan'],
} }
hwmon_nodes = {'led': ['brightness'] , hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'], 'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import commands import commands
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -23,17 +23,11 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as7716_32x.fanutil import FanUtil from as7716_32x.fanutil import FanUtil
from as7716_32x.thermalutil import ThermalUtil from as7716_32x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,13 +30,11 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time
from collections import namedtuple
PROJECT_NAME = 'as7716_32xb' PROJECT_NAME = 'as7716_32xb'
version = '0.0.1' version = '0.0.1'
@ -55,7 +53,6 @@ hwmon_types = {'led': ['diag','fan','loc','psu1','psu2'],
'fan3': ['fan'], 'fan3': ['fan'],
'fan4': ['fan'], 'fan4': ['fan'],
'fan5': ['fan'], 'fan5': ['fan'],
'fan5': ['fan'],
} }
hwmon_nodes = {'led': ['brightness'] , hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'], 'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],

View File

@ -24,17 +24,12 @@
try: try:
import os import os
import sys, getopt import getopt
import subprocess import sys
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as7726_32x.fanutil import FanUtil from as7726_32x.fanutil import FanUtil
from as7726_32x.thermalutil import ThermalUtil from as7726_32x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,19 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as7726_32x' PROJECT_NAME = 'as7726_32x'
version = '0.0.1' version = '0.0.1'
@ -55,7 +54,6 @@ hwmon_types = {'led': ['diag','fan','loc','psu1','psu2'],
'fan3': ['fan'], 'fan3': ['fan'],
'fan4': ['fan'], 'fan4': ['fan'],
'fan5': ['fan'], 'fan5': ['fan'],
'fan5': ['fan'],
} }
hwmon_nodes = {'led': ['brightness'] , hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'], 'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],

View File

@ -24,18 +24,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
import signal import signal
from tabulate import tabulate
from as7816_64x.fanutil import FanUtil from as7816_64x.fanutil import FanUtil
from as7816_64x.thermalutil import ThermalUtil from as7816_64x.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -30,14 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple

View File

@ -20,19 +20,13 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os
import commands import commands
import sys, getopt import getopt
import subprocess import sys
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
from as9716_32d.fanutil import FanUtil from as9716_32d.fanutil import FanUtil
from as9716_32d.thermalutil import ThermalUtil from as9716_32d.thermalutil import ThermalUtil
except ImportError as e: except ImportError as e:

View File

@ -22,19 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -22,18 +22,12 @@
# ------------------------------------------------------------------ # ------------------------------------------------------------------
try: try:
import os import getopt
import sys, getopt import sys
import subprocess
import click
import imp
import logging import logging
import logging.config import logging.config
import logging.handlers import logging.handlers
import types
import time # this is only being used as part of the example import time # this is only being used as part of the example
import traceback
from tabulate import tabulate
except ImportError as e: except ImportError as e:
raise ImportError('%s - required module not found' % str(e)) raise ImportError('%s - required module not found' % str(e))

View File

@ -30,13 +30,12 @@ command:
set : change board setting with fan|led|sfp set : change board setting with fan|led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'as9716_32d' PROJECT_NAME = 'as9716_32d'
version = '0.0.1' version = '0.0.1'
@ -55,7 +54,6 @@ hwmon_types = {'led': ['diag','fan','loc','psu1','psu2'],
'fan3': ['fan'], 'fan3': ['fan'],
'fan4': ['fan'], 'fan4': ['fan'],
'fan5': ['fan'], 'fan5': ['fan'],
'fan5': ['fan'],
} }
hwmon_nodes = {'led': ['brightness'] , hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'], 'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],

View File

@ -37,13 +37,12 @@ command:
set : change board setting with led|sfp set : change board setting with led|sfp
""" """
import os
import commands import commands
import sys, getopt import getopt
import sys
import logging import logging
import re import re
import time import time
from collections import namedtuple
PROJECT_NAME = 'minipack' PROJECT_NAME = 'minipack'
version = '0.2.0' version = '0.2.0'

View File

@ -22,8 +22,8 @@
try: try:
import os import os
import sys, getopt import getopt
import subprocess import sys
import subprocess import subprocess
import click import click
import imp import imp

View File

@ -335,7 +335,7 @@ def system_get_lswtemp():
return 25 return 25
# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) # chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE)
# if chp.poll() == None: # if chp.poll() is None:
# misclogger.info("No subp.") # misclogger.info("No subp.")
# chp.kill() # chp.kill()
# #

View File

@ -335,7 +335,7 @@ def system_get_lswtemp():
return 25 return 25
# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) # chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE)
# if chp.poll() == None: # if chp.poll() is None:
# misclogger.info("No subp.") # misclogger.info("No subp.")
# chp.kill() # chp.kill()
# #

View File

@ -335,7 +335,7 @@ def system_get_lswtemp():
return 25 return 25
# chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE) # chp = subprocess.Popen("docker ps --filter name=syncd", shell=True, stdout=subprocess.PIPE)
# if chp.poll() == None: # if chp.poll() is None:
# misclogger.info("No subp.") # misclogger.info("No subp.")
# chp.kill() # chp.kill()
# #

View File

@ -1,5 +1,3 @@
import os
import sys
from natsort import natsorted from natsort import natsorted
def generate_t1_sample_config(data): def generate_t1_sample_config(data):

View File

@ -1,15 +1,10 @@
from __future__ import print_function from __future__ import print_function
import calendar import ipaddress
from ipaddress import IPv4Address, IPv4Network, ip_address, ip_network
import math import math
import os import os
import sys import sys
import socket
import struct
import json import json
import copy
import ipaddress
from collections import defaultdict from collections import defaultdict
from lxml import etree as ET from lxml import etree as ET
@ -809,7 +804,7 @@ def parse_spine_chassis_fe(results, vni, lo_intfs, phyport_intfs, pc_intfs, pc_m
intf_name = pc_member[1] intf_name = pc_member[1]
break break
if intf_name == None: if intf_name is None:
print('Warning: cannot find any interfaces that belong to %s' % (pc_intf), file=sys.stderr) print('Warning: cannot find any interfaces that belong to %s' % (pc_intf), file=sys.stderr)
continue continue
@ -1314,8 +1309,8 @@ def get_tunnel_entries(tunnel_intfs, lo_intfs, hostname):
lo_addr = '' lo_addr = ''
# Use the first IPv4 loopback as the tunnel destination IP # Use the first IPv4 loopback as the tunnel destination IP
for addr in lo_intfs.keys(): for addr in lo_intfs.keys():
ip_addr = ip_network(UNICODE_TYPE(addr[1])) ip_addr = ipaddress.ip_network(UNICODE_TYPE(addr[1]))
if isinstance(ip_addr, IPv4Network): if isinstance(ip_addr, ipaddress.IPv4Network):
lo_addr = str(ip_addr.network_address) lo_addr = str(ip_addr.network_address)
break break

View File

@ -1,10 +1,10 @@
try: try:
import os
import sys
import json
import ast import ast
import json
import os
import re import re
from collections import OrderedDict import sys
from swsssdk import ConfigDBConnector from swsssdk import ConfigDBConnector
from sonic_py_common import device_info from sonic_py_common import device_info
except ImportError as e: except ImportError as e: