Skip to content

Commit

Permalink
Fix a number of LGTM alerts (#5952)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jleveque authored Nov 20, 2020
1 parent 461e436 commit 2324751
Show file tree
Hide file tree
Showing 57 changed files with 114 additions and 322 deletions.
2 changes: 1 addition & 1 deletion device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def get_transceiver_change_event(self, timeout=0):
phy_port_dict = {}
status = True

if self.db_sel == None:
if self.db_sel is None:
from swsscommon import swsscommon
self.state_db = swsscommon.DBConnector("STATE_DB",
REDIS_TIMEOUT_USECS,
Expand Down
2 changes: 1 addition & 1 deletion files/build_scripts/generate_asic_config_checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def generate_checksum(checksum_files):
def main():
config_files = sorted(get_config_files(CONFIG_FILES))
checksum = generate_checksum(config_files)
if checksum == None:
if checksum is None:
exit(1)

with open(OUTPUT_FILE, 'w') as output:
Expand Down
1 change: 0 additions & 1 deletion files/image_config/corefile_uploader/core_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def handle_file(path):
def upload_file(fname, fpath, coref):
daemonname = fname.split(".")[0]
i = 0
fail_msg = ""

while True:
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time
import traceback
import commands
from tabulate import tabulate
from as4630_54pe.fanutil import FanUtil
from as4630_54pe.thermalutil import ThermalUtil
except ImportError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time # this is only being used as part of the example
import traceback
from tabulate import tabulate

except ImportError as e:
raise ImportError('%s - required module not found' % str(e))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
# ------------------------------------------------------------------

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
set : change board setting with fan|led|sfp
"""

import os
import commands
import sys, getopt
import getopt
import sys
import logging
import re
import time
from collections import namedtuple

PROJECT_NAME = 'as4630_54pe'
version = '0.0.1'
Expand All @@ -54,7 +53,6 @@
'fan3': ['fan'],
'fan4': ['fan'],
'fan5': ['fan'],
'fan5': ['fan'],
}
hwmon_nodes = {'led': ['brightness'] ,
'fan1': ['fan_duty_cycle_percentage', 'fan1_fault', 'fan1_speed_rpm', 'fan1_direction', 'fanr1_fault', 'fanr1_speed_rpm'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import logging
import logging.config
import types
import time # this is only being used as part of the example
import traceback
import signal
from tabulate import tabulate
from as5712_54x.fanutil import FanUtil
from as5712_54x.thermalutil import ThermalUtil
except ImportError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

import os
import commands
import sys, getopt
import getopt
import sys
import logging
import re
import time
from collections import namedtuple

PROJECT_NAME = 'as5712_54x'
version = '0.2.0'
Expand Down Expand Up @@ -546,15 +546,15 @@ def cpld_path_of_port(port_index):

def get_path_sfp_tx_dis(port_index):
cpld_p = cpld_path_of_port(port_index)
if cpld_p == None:
if cpld_p is None:
return False, ''
else:
dev = cpld_p+"module_tx_disable_"+str(port_index)
return True, dev

def get_path_sfp_presence(port_index):
cpld_p = cpld_path_of_port(port_index)
if cpld_p == None:
if cpld_p is None:
return False, ''
else:
dev = cpld_p+"module_present_"+str(port_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time # this is only being used as part of the example
import traceback
import signal
from tabulate import tabulate
from as5812_54t.fanutil import FanUtil
from as5812_54t.thermalutil import ThermalUtil
except ImportError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
set : change board setting with fan|led|sfp
"""

import os
import commands
import sys, getopt
import getopt
import sys
import logging
import re
import time
from collections import namedtuple



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time # this is only being used as part of the example
import traceback
import signal
from tabulate import tabulate
from as5812_54x.fanutil import FanUtil
from as5812_54x.thermalutil import ThermalUtil
except ImportError as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

import os
import commands
import sys, getopt
import getopt
import sys
import logging
import re
import time
from collections import namedtuple

PROJECT_NAME = 'as5812_54x'
version = '0.2.0'
Expand Down Expand Up @@ -546,15 +546,15 @@ def cpld_path_of_port(port_index):

def get_path_sfp_tx_dis(port_index):
cpld_p = cpld_path_of_port(port_index)
if cpld_p == None:
if cpld_p is None:
return False, ''
else:
dev = cpld_p+"module_tx_disable_"+str(port_index)
return True, dev

def get_path_sfp_presence(port_index):
cpld_p = cpld_path_of_port(port_index)
if cpld_p == None:
if cpld_p is None:
return False, ''
else:
dev = cpld_p+"module_present_"+str(port_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,12 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import types
import time # this is only being used as part of the example
import traceback
import signal
from tabulate import tabulate
from as5835_54t.fanutil import FanUtil
from as5835_54t.thermalutil import ThermalUtil
except ImportError as e:
Expand Down Expand Up @@ -203,4 +197,4 @@ def main(argv):
time.sleep(10)

if __name__ == '__main__':
main(sys.argv[1:])
main(sys.argv[1:])
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time # this is only being used as part of the example
import traceback
from tabulate import tabulate

except ImportError as e:
raise ImportError('%s - required module not found' % str(e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
# ------------------------------------------------------------------

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
set : change board setting with fan|led|sfp
"""

import os
import commands
import sys, getopt
import getopt
import sys
import logging
import re
import time
from collections import namedtuple



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import types
import time # this is only being used as part of the example
import traceback
import signal
from tabulate import tabulate
from as5835_54x.fanutil import FanUtil
from as5835_54x.thermalutil import ThermalUtil
except ImportError as e:
Expand Down Expand Up @@ -202,4 +196,4 @@ def main(argv):
time.sleep(10)

if __name__ == '__main__':
main(sys.argv[1:])
main(sys.argv[1:])
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
# ------------------------------------------------------------------

try:
import os
import sys, getopt
import subprocess
import click
import imp
import getopt
import sys
import logging
import logging.config
import logging.handlers
import types
import time # this is only being used as part of the example
import traceback
from tabulate import tabulate

except ImportError as e:
raise ImportError('%s - required module not found' % str(e))
Expand Down
Loading

0 comments on commit 2324751

Please sign in to comment.