Skip to content

Commit

Permalink
Fix LGTM issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Keene committed Nov 5, 2020
1 parent 842a094 commit b16feec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 48 deletions.
27 changes: 9 additions & 18 deletions device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/led_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

try:
from sonic_led.led_control_base import LedControlBase
import swsssdk
import threading
import os
import logging
import struct
import time
import syslog
from socket import *
Expand All @@ -28,24 +24,20 @@
except ImportError, e:
smbus_present = 0


def DBG_PRINT(str):
syslog.openlog("nokia-led")
syslog.syslog(syslog.LOG_INFO, str)
syslog.closelog()



class LedControl(LedControlBase):
"""Platform specific LED control class"""

# Constructor
def __init__(self):
MV_GPIO_DIR = "/sys/class/gpio/"
self.chassis = sonic_platform.platform.Platform().get_chassis()
self._initDefaultConfig()


def _initDefaultConfig(self):
# For the D1 box the port leds are controlled by Trident3 LED program
# The fan tray leds will be managed with the new thermalctl daemon / chassis class based API
Expand All @@ -61,11 +53,10 @@ def _set_i2c_register(self, reg_file, value):

if (not os.path.isfile(reg_file)):
return rv

try:
with open(reg_file, 'w') as fd:
rv = fd.write(str(value))
except:
except Exception as e:
rv = 'ERR'

return rv
Expand All @@ -91,31 +82,31 @@ def _initSystemLed(self):
if ( self.chassis.get_fan(0).get_status() == self.chassis.get_fan(1).get_status() == True ):
if oldfan != 0x1:
if (os.path.isfile("/sys/class/gpio/fanLedAmber/value")):
rv = self._set_i2c_register("/sys/class/gpio/fanLedAmber/value" , 0 )
rv = self._set_i2c_register("/sys/class/gpio/fanLedGreen/value" , 1 )
self._set_i2c_register("/sys/class/gpio/fanLedAmber/value" , 0 )
self._set_i2c_register("/sys/class/gpio/fanLedGreen/value" , 1 )
oldfan = 0x1
#DBG_PRINT(" System FAN LED set GRN ")
else:
if oldfan != 0x0:
if (os.path.isfile("/sys/class/gpio/fanLedGreen/value")):
rv = self._set_i2c_register("/sys/class/gpio/fanLedGreen/value" , 0 )
rv = self._set_i2c_register("/sys/class/gpio/fanLedAmber/value" , 1 )
self._set_i2c_register("/sys/class/gpio/fanLedGreen/value" , 0 )
self._set_i2c_register("/sys/class/gpio/fanLedAmber/value" , 1 )
oldfan = 0x0
#DBG_PRINT(" System FAN LED set AMBER ")

# Front Panel PSU Panel LED setting in register 0x09
if ( self.chassis.get_psu(0).get_status() == self.chassis.get_psu(1).get_status() == True ):
if oldpsu != 0x1:
if (os.path.isfile("/sys/class/gpio/psuLedAmber/value")):
rv = self._set_i2c_register("/sys/class/gpio/psuLedAmber/value" , 0 )
rv = self._set_i2c_register("/sys/class/gpio/psuLedGreen/value" , 1 )
self._set_i2c_register("/sys/class/gpio/psuLedAmber/value" , 0 )
self._set_i2c_register("/sys/class/gpio/psuLedGreen/value" , 1 )
oldpsu =0x1
#DBG_PRINT(" System PSU LED set GRN ")
else:
if oldpsu != 0x0:
if (os.path.isfile("/sys/class/gpio/psuLedGreen/value")):
rv = self._set_i2c_register("/sys/class/gpio/psuLedGreen/value" , 0 )
rv = self._set_i2c_register("/sys/class/gpio/psuLedAmber/value" , 1 )
self._set_i2c_register("/sys/class/gpio/psuLedGreen/value" , 0 )
self._set_i2c_register("/sys/class/gpio/psuLedAmber/value" , 1 )
oldpsu =0x0
#DBG_PRINT(" System PSU LED set AMBER ")
time.sleep(6)
Expand Down
11 changes: 0 additions & 11 deletions device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#!/usr/bin/env python

import sys
import os.path
if sys.version_info[0] < 3:
import commands as cmd
else:
import subprocess as cmd

smbus_present = 1
try:
import smbus
except ImportError as e:
smbus_present = 0

try:
import sonic_platform.platform
Expand Down
20 changes: 1 addition & 19 deletions device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
#!/usr/bin/env python

try:
import os
import time
import re
import sys
import glob
import sonic_platform.platform
import sonic_platform.chassis
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError, e:
raise ImportError (str(e) + "- required module not found")

if sys.version_info[0] < 3:
import commands as cmd
else:
import subprocess as cmd

smbus_present = 1

try:
import smbus
except ImportError, e:
smbus_present = 0

class SfpUtil(SfpUtilBase):
"""Platform specific sfputil class"""
Expand Down Expand Up @@ -66,7 +51,6 @@ def reset(self, port_num):
else:
print "chassis was None error "


def set_low_power_mode(self, port_nuM, lpmode):
# print " SfpUtil(SfpUtilBase) targeted for deprecation "
return False
Expand All @@ -80,12 +64,10 @@ def get_presence(self, port_num):
if self.chassis is not None:
return self.chassis.get_sfp(port_num).get_presence()
else:
print "chassis was None error "

print "chassis was None error "

def get_transceiver_change_event(self, timeout):
# print " SfpUtil(SfpUtilBase) targeted for deprecation "
port_dict = {}

raise NotImplementedError

Expand Down

0 comments on commit b16feec

Please sign in to comment.