Skip to content

Commit f23935c

Browse files
[as4630-54te] Fix LGTM alerts.
1 parent cdc1291 commit f23935c

File tree

9 files changed

+5
-57
lines changed

9 files changed

+5
-57
lines changed

device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
#!/usr/bin/env python
22

33
try:
4-
import binascii
5-
import time
6-
import optparse
7-
import warnings
8-
import os
9-
import sys
10-
from sonic_eeprom import eeprom_base
114
from sonic_eeprom import eeprom_tlvinfo
12-
import subprocess
5+
136
except ImportError as e:
147
raise ImportError(str(e) + "- required module not found")
158

device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#
99
#############################################################################
1010

11-
import os.path
1211

1312
try:
1413
from sonic_psu.psu_base import PsuBase

device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py

-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
try:
77
import sys
88
import time
9-
import string
109
from ctypes import create_string_buffer
1110
from sonic_sfp.sfputilbase import SfpUtilBase
1211
except ImportError as e:
@@ -71,7 +70,6 @@ def get_presence(self, port_num):
7170
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
7271
self.__port_to_is_present = present_path
7372

74-
content = "0"
7573
try:
7674
val_file = open(self.__port_to_is_present)
7775
content = val_file.readline().rstrip()
@@ -196,4 +194,3 @@ def get_transceiver_change_event(self, timeout=0):
196194
return True, port_dict
197195
else:
198196
return True, {}
199-
return False, {}

platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/fanutil.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
# ------------------------------------------------------------------
2121

2222
try:
23-
import time
2423
import logging
25-
from collections import namedtuple
2624
except ImportError as e:
2725
raise ImportError('%s - required module not found' % str(e))
2826

@@ -95,7 +93,7 @@ def _get_fan_node_val(self, fan_num, node_num):
9593

9694
try:
9795
val_file.close()
98-
except BaseException:
96+
except Exception:
9997
logging.debug(
10098
'GET. unable to close file. device_path:%s',
10199
device_path)

platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/thermalutil.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@
2020
# ------------------------------------------------------------------
2121

2222
try:
23-
import os
24-
import time
2523
import logging
2624
import glob
27-
import commands
28-
from collections import namedtuple
2925
except ImportError as e:
3026
raise ImportError('%s - required module not found' % str(e))
3127

@@ -90,7 +86,7 @@ def get_thermal_path(self, thermal_num):
9086

9187

9288
def main():
93-
thermal = ThermalUtil()
89+
ThermalUtil()
9490

9591

9692
if __name__ == '__main__':

platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@
2020
# ------------------------------------------------------------------
2121

2222
try:
23-
import os
2423
import sys
2524
import getopt
26-
import subprocess
27-
import imp
2825
import logging
2926
import logging.config
3027
import logging.handlers
31-
import types
3228
import time
33-
import traceback
3429
import commands
3530
from as4630_54te.fanutil import FanUtil
3631
from as4630_54te.thermalutil import ThermalUtil
@@ -41,10 +36,6 @@
4136
VERSION = '1.0'
4237
FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor'
4338

44-
global log_file
45-
global log_level
46-
47-
4839
# Temperature Policy
4940
# If any fan fail , please set fan speed register to 16
5041
# The max value of fan speed register is 14
@@ -113,7 +104,7 @@ def __init__(self, log_file, log_level):
113104
console.setFormatter(formatter)
114105
logging.getLogger('').addHandler(console)
115106

116-
sys_handler = handler = logging.handlers.SysLogHandler(
107+
sys_handler = logging.handlers.SysLogHandler(
117108
address='/dev/log')
118109
sys_handler.setLevel(logging.WARNING)
119110
logging.getLogger('').addHandler(sys_handler)
@@ -148,7 +139,6 @@ def manage_fans(self):
148139
LEVEL_TEMP_CRITICAL: [100, 16, 240000, 300000],
149140
}
150141
temp = [0, 0, 0]
151-
temp_fail = 0
152142
thermal = ThermalUtil()
153143
fan = FanUtil()
154144
ori_duty_cycle = fan.get_fan_duty_cycle()
@@ -158,7 +148,6 @@ def manage_fans(self):
158148
for i in range(0, 3):
159149
temp[i] = thermal._get_thermal_val(i + 1)
160150
if temp[i] == 0 or temp[i] is None:
161-
temp_fail = 1
162151
logging.warning("Get temp-%d fail", i)
163152
return False
164153
else:
@@ -207,7 +196,6 @@ def manage_fans(self):
207196
'Alarm-Critical for temperature critical is detected, reset DUT')
208197
cmd_str = "i2cset -y -f 3 0x60 0x4 0xE4"
209198
time.sleep(2)
210-
status, output = commands.getstatusoutput(cmd_str)
211199

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

platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_fan.py

-8
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@
2222
# ------------------------------------------------------------------
2323

2424
try:
25-
import os
2625
import sys
2726
import getopt
28-
import subprocess
29-
import imp
3027
import logging
3128
import logging.config
3229
import logging.handlers
33-
import types
3430
import time # this is only being used as part of the example
35-
import traceback
3631

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

44-
global log_file
45-
global log_level
46-
4739

4840
class switch(object):
4941
def __init__(self, value):

platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_psu.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,20 @@
2222
# ------------------------------------------------------------------
2323

2424
try:
25-
import os
2625
import sys
2726
import getopt
28-
import subprocess
29-
import imp
3027
import logging
3128
import logging.config
3229
import logging.handlers
33-
import types
3430
import time # this is only being used as part of the example
35-
import traceback
31+
3632
except ImportError as e:
3733
raise ImportError('%s - required module not found' % str(e))
3834

3935
# Deafults
4036
VERSION = '1.0'
4137
FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor_psu'
4238

43-
global log_file
44-
global log_level
45-
4639

4740
psu_state = [2, 2]
4841
psu_status_state = [2, 2]

platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py

-8
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
'fan3': ['fan'],
6565
'fan4': ['fan'],
6666
'fan5': ['fan'],
67-
'fan5': ['fan'],
6867
}
6968
hwmon_nodes = {
7069
'led': ['brightness'],
@@ -161,7 +160,6 @@
161160

162161

163162
if DEBUG:
164-
print sys.argv[0]
165163
print 'ARGV :', sys.argv[1:]
166164

167165

@@ -252,7 +250,6 @@ def my_log(txt):
252250

253251
def log_os_system(cmd, show):
254252
logging.info('Run :' + cmd)
255-
status = 1
256253
output = ""
257254
status, output = commands.getstatusoutput(cmd)
258255
my_log(cmd + "with result:" + str(status))
@@ -288,7 +285,6 @@ def driver_inserted():
288285
def driver_install():
289286
global FORCE
290287

291-
ret = log_os_system("lsmod|grep i2c_ismt", 1)
292288
my_log("rmmond i2cismt")
293289
log_os_system("rmmod i2c_ismt", 1)
294290
log_os_system("rmmod i2c_i801", 1)
@@ -368,10 +364,6 @@ def device_uninstall():
368364
global FORCE
369365

370366
status, output = log_os_system("ls /sys/bus/i2c/devices/0-0070", 0)
371-
if status == 0:
372-
I2C_ORDER = 1
373-
else:
374-
I2C_ORDER = 0
375367

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

0 commit comments

Comments
 (0)