Skip to content

Commit

Permalink
[as4630-54te] Fix LGTM alerts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ec-michael-shih committed Feb 23, 2021
1 parent cdc1291 commit f23935c
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 57 deletions.
9 changes: 1 addition & 8 deletions device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/usr/bin/env python

try:
import binascii
import time
import optparse
import warnings
import os
import sys
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess

except ImportError as e:
raise ImportError(str(e) + "- required module not found")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#
#############################################################################

import os.path

try:
from sonic_psu.psu_base import PsuBase
Expand Down
3 changes: 0 additions & 3 deletions device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
try:
import sys
import time
import string
from ctypes import create_string_buffer
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
Expand Down Expand Up @@ -71,7 +70,6 @@ def get_presence(self, port_num):
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
self.__port_to_is_present = present_path

content = "0"
try:
val_file = open(self.__port_to_is_present)
content = val_file.readline().rstrip()
Expand Down Expand Up @@ -196,4 +194,3 @@ def get_transceiver_change_event(self, timeout=0):
return True, port_dict
else:
return True, {}
return False, {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
# ------------------------------------------------------------------

try:
import time
import logging
from collections import namedtuple
except ImportError as e:
raise ImportError('%s - required module not found' % str(e))

Expand Down Expand Up @@ -95,7 +93,7 @@ def _get_fan_node_val(self, fan_num, node_num):

try:
val_file.close()
except BaseException:
except Exception:
logging.debug(
'GET. unable to close file. device_path:%s',
device_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
# ------------------------------------------------------------------

try:
import os
import time
import logging
import glob
import commands
from collections import namedtuple
except ImportError as e:
raise ImportError('%s - required module not found' % str(e))

Expand Down Expand Up @@ -90,7 +86,7 @@ def get_thermal_path(self, thermal_num):


def main():
thermal = ThermalUtil()
ThermalUtil()


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@
# ------------------------------------------------------------------

try:
import os
import sys
import getopt
import subprocess
import imp
import logging
import logging.config
import logging.handlers
import types
import time
import traceback
import commands
from as4630_54te.fanutil import FanUtil
from as4630_54te.thermalutil import ThermalUtil
Expand All @@ -41,10 +36,6 @@
VERSION = '1.0'
FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor'

global log_file
global log_level


# Temperature Policy
# If any fan fail , please set fan speed register to 16
# The max value of fan speed register is 14
Expand Down Expand Up @@ -113,7 +104,7 @@ def __init__(self, log_file, log_level):
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)

sys_handler = handler = logging.handlers.SysLogHandler(
sys_handler = logging.handlers.SysLogHandler(
address='/dev/log')
sys_handler.setLevel(logging.WARNING)
logging.getLogger('').addHandler(sys_handler)
Expand Down Expand Up @@ -148,7 +139,6 @@ def manage_fans(self):
LEVEL_TEMP_CRITICAL: [100, 16, 240000, 300000],
}
temp = [0, 0, 0]
temp_fail = 0
thermal = ThermalUtil()
fan = FanUtil()
ori_duty_cycle = fan.get_fan_duty_cycle()
Expand All @@ -158,7 +148,6 @@ def manage_fans(self):
for i in range(0, 3):
temp[i] = thermal._get_thermal_val(i + 1)
if temp[i] == 0 or temp[i] is None:
temp_fail = 1
logging.warning("Get temp-%d fail", i)
return False
else:
Expand Down Expand Up @@ -207,7 +196,6 @@ def manage_fans(self):
'Alarm-Critical for temperature critical is detected, reset DUT')
cmd_str = "i2cset -y -f 3 0x60 0x4 0xE4"
time.sleep(2)
status, output = commands.getstatusoutput(cmd_str)

#logging.debug('ori_state=%d, current_state=%d, temp_val=%d\n\n',ori_state, fan_policy_state, temp_val)

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

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

except ImportError as e:
raise ImportError('%s - required module not found' % str(e))
Expand All @@ -41,9 +36,6 @@
VERSION = '1.0'
FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor_fan'

global log_file
global log_level


class switch(object):
def __init__(self, value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,20 @@
# ------------------------------------------------------------------

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

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

# Deafults
VERSION = '1.0'
FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor_psu'

global log_file
global log_level


psu_state = [2, 2]
psu_status_state = [2, 2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
'fan3': ['fan'],
'fan4': ['fan'],
'fan5': ['fan'],
'fan5': ['fan'],
}
hwmon_nodes = {
'led': ['brightness'],
Expand Down Expand Up @@ -161,7 +160,6 @@


if DEBUG:
print sys.argv[0]
print 'ARGV :', sys.argv[1:]


Expand Down Expand Up @@ -252,7 +250,6 @@ def my_log(txt):

def log_os_system(cmd, show):
logging.info('Run :' + cmd)
status = 1
output = ""
status, output = commands.getstatusoutput(cmd)
my_log(cmd + "with result:" + str(status))
Expand Down Expand Up @@ -288,7 +285,6 @@ def driver_inserted():
def driver_install():
global FORCE

ret = log_os_system("lsmod|grep i2c_ismt", 1)
my_log("rmmond i2cismt")
log_os_system("rmmod i2c_ismt", 1)
log_os_system("rmmod i2c_i801", 1)
Expand Down Expand Up @@ -368,10 +364,6 @@ def device_uninstall():
global FORCE

status, output = log_os_system("ls /sys/bus/i2c/devices/0-0070", 0)
if status == 0:
I2C_ORDER = 1
else:
I2C_ORDER = 0

for i in range(0, len(sfp_map)):
target = "/sys/bus/i2c/devices/i2c-" + \
Expand Down

0 comments on commit f23935c

Please sign in to comment.