Update Accton platform module for Bullseye and 5.10 kernel
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
parent
8bc8b96c4a
commit
3a3b45db3a
@ -4,7 +4,7 @@ include $(PLATFORM_PATH)/platform-modules-nokia.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-dell.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-arista.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-ingrasys.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-accton.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-accton.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-alphanetworks.mk
|
||||
#include $(PLATFORM_PATH)/platform-modules-inventec.mk
|
||||
include $(PLATFORM_PATH)/platform-modules-cel.mk
|
||||
|
@ -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))
|
||||
|
||||
@ -82,24 +80,24 @@ class FanUtil(object):
|
||||
|
||||
device_path = self.get_fan_device_path(fan_num, node_num)
|
||||
|
||||
try:
|
||||
val_file = open(device_path, 'r')
|
||||
except IOError as e:
|
||||
logging.error('GET. unable to open file: %s', str(e))
|
||||
return None
|
||||
try:
|
||||
val_file = open(device_path, 'r')
|
||||
except IOError as e:
|
||||
logging.error('GET. unable to open file: %s', str(e))
|
||||
return None
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
if content == '':
|
||||
logging.debug('GET. content is NULL. device_path:%s', device_path)
|
||||
return None
|
||||
content = val_file.readline().rstrip()
|
||||
if content == '':
|
||||
logging.debug('GET. content is NULL. device_path:%s', device_path)
|
||||
return None
|
||||
|
||||
try:
|
||||
val_file.close()
|
||||
except:
|
||||
logging.debug('GET. unable to close file. device_path:%s', device_path)
|
||||
return None
|
||||
|
||||
return int(content)
|
||||
try:
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
logging.debug('GET. unable to close file: %s. device_path:%s', str(e), device_path)
|
||||
return None
|
||||
|
||||
return int(content)
|
||||
|
||||
def _set_fan_node_val(self, fan_num, node_num, val):
|
||||
if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD:
|
||||
@ -125,9 +123,9 @@ class FanUtil(object):
|
||||
val_file.write(content)
|
||||
|
||||
try:
|
||||
val_file.close()
|
||||
except:
|
||||
logging.debug('GET. unable to close file. device_path:%s', device_path)
|
||||
val_file.close()
|
||||
except IOError as e:
|
||||
logging.debug('GET. unable to close file: %s. device_path:%s', str(e), device_path)
|
||||
return None
|
||||
|
||||
return True
|
||||
@ -158,7 +156,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -170,7 +168,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
fan_file.write(str(val))
|
||||
|
@ -24,7 +24,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
|
@ -26,7 +26,7 @@ try:
|
||||
import logging.config
|
||||
import logging.handlers
|
||||
import time
|
||||
import commands
|
||||
import subprocess
|
||||
from as4630_54pe.fanutil import FanUtil
|
||||
from as4630_54pe.thermalutil import ThermalUtil
|
||||
except ImportError as e:
|
||||
@ -200,7 +200,7 @@ class device_monitor(object):
|
||||
logging.critical('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)
|
||||
status, output = subprocess.getstatusoutput(cmd_str)
|
||||
|
||||
#logging.debug('ori_state=%d, current_state=%d, temp_val=%d\n\n',ori_state, fan_policy_state, temp_val)
|
||||
|
||||
@ -225,11 +225,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -238,7 +238,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1]== '-t':
|
||||
if len(sys.argv)!=5:
|
||||
print "temp test, need input three temp"
|
||||
print("temp test, need input three temp")
|
||||
return 0
|
||||
|
||||
i=0
|
||||
@ -247,11 +247,11 @@ def main(argv):
|
||||
i=i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(50)
|
||||
print "set default fan speed to 50%"
|
||||
print("set default fan speed to 50%")
|
||||
monitor = device_monitor(log_file, log_level)
|
||||
# Loop forever, doing something useful hopefully:
|
||||
while True:
|
||||
|
@ -124,7 +124,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -143,7 +143,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -165,11 +165,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -96,7 +96,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -143,11 +143,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -88,8 +88,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
print((sys.argv[0]))
|
||||
print(('ARGV :', sys.argv[1:]))
|
||||
|
||||
|
||||
def main():
|
||||
@ -107,7 +107,7 @@ def main():
|
||||
if DEBUG == True:
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
print((len(sys.argv)))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -132,12 +132,12 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
print(( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}))
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print("[ACCTON DBG]: ",txt)
|
||||
print(("[ACCTON DBG]: ",txt))
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
@ -151,7 +151,7 @@ def log_os_system(cmd, show):
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -294,14 +294,14 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
print((PROJECT_NAME.upper()+" drivers detected...."))
|
||||
if not device_exist():
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
print((PROJECT_NAME.upper()+" devices detected...."))
|
||||
|
||||
for i in range(len(cpld_set)):
|
||||
status, output = log_os_system(cpld_set[i], 1)
|
||||
@ -312,7 +312,7 @@ def do_install():
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print(PROJECT_NAME.upper()+" has no device installed....")
|
||||
print((PROJECT_NAME.upper()+" has no device installed...."))
|
||||
else:
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
@ -321,7 +321,7 @@ def do_uninstall():
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print(PROJECT_NAME.upper()+" has no driver installed....")
|
||||
print((PROJECT_NAME.upper()+" has no driver installed...."))
|
||||
else:
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
|
@ -165,7 +165,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -177,7 +177,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
fan_file.write(str(val))
|
||||
|
@ -223,11 +223,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdlt:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -236,7 +236,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1] == '-t':
|
||||
if len(sys.argv) != 5:
|
||||
print "temp test, need input three temp"
|
||||
print("temp test, need input three temp")
|
||||
return 0
|
||||
|
||||
i = 0
|
||||
@ -245,11 +245,11 @@ def main(argv):
|
||||
i = i + 1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(50)
|
||||
print "set default fan speed to 50%"
|
||||
print("set default fan speed to 50%")
|
||||
monitor = device_monitor(log_file, log_level)
|
||||
# Loop forever, doing something useful hopefully:
|
||||
while True:
|
||||
|
@ -122,7 +122,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -142,7 +142,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -166,11 +166,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdl:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -96,7 +96,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -120,7 +120,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -147,11 +147,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdl:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -29,7 +29,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -165,8 +165,8 @@ def main():
|
||||
global FORCE
|
||||
|
||||
if DEBUG:
|
||||
print(sys.argv[0])
|
||||
print('ARGV : %s' % sys.argv[1:])
|
||||
print((sys.argv[0]))
|
||||
print(('ARGV : %s' % sys.argv[1:]))
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
show_help()
|
||||
@ -176,9 +176,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -189,7 +189,7 @@ def main():
|
||||
elif opt in ('-f', '--force'):
|
||||
FORCE = 1
|
||||
else:
|
||||
print "TEST"
|
||||
print("TEST")
|
||||
logging.info('no option')
|
||||
for arg in args:
|
||||
if arg == 'install':
|
||||
@ -223,42 +223,42 @@ def main():
|
||||
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName': sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName': sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1] + " " + args[0]
|
||||
print cmd + " [led|sfp|fan]"
|
||||
print " use \"" + cmd + " led 0-4 \" to set led color"
|
||||
print " use \"" + cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \"" + cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd + " [led|sfp|fan]")
|
||||
print(" use \"" + cmd + " led 0-4 \" to set led color")
|
||||
print(" use \"" + cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \"" + cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1] + " " + args[0]
|
||||
print " use \"" + cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \"" + cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG:
|
||||
print "[ACCTON DBG]: " + txt
|
||||
print("[ACCTON DBG]: " + txt)
|
||||
return
|
||||
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :' + cmd)
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log(cmd + "with result:" + str(status))
|
||||
my_log("cmd:" + cmd)
|
||||
my_log(" output:" + output)
|
||||
if status:
|
||||
logging.info('Failed :' + cmd)
|
||||
if show:
|
||||
print('Failed :' + cmd)
|
||||
print(('Failed :' + cmd))
|
||||
return status, output
|
||||
|
||||
|
||||
@ -306,7 +306,7 @@ def driver_uninstall():
|
||||
for i in range(0, len(kos)):
|
||||
rm = kos[-(i + 1)].replace("modprobe", "modprobe -rq")
|
||||
lst = rm.split(" ")
|
||||
print "lst=%s" % lst
|
||||
print("lst=%s" % lst)
|
||||
if len(lst) > 3:
|
||||
del(lst[3])
|
||||
rm = " ".join(lst)
|
||||
@ -327,7 +327,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
print("Check SFP")
|
||||
@ -342,7 +342,7 @@ def device_install():
|
||||
str(sfp_map[i]) +
|
||||
"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -353,7 +353,7 @@ def device_install():
|
||||
str(sfp_map[i]) +
|
||||
"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -368,7 +368,7 @@ def device_uninstall():
|
||||
str(sfp_map[i]) + "/delete_device"
|
||||
status, output = log_os_system("echo 0x50 > " + target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -381,7 +381,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -392,7 +392,7 @@ def system_ready():
|
||||
if driver_inserted() == False:
|
||||
return False
|
||||
if not device_exist():
|
||||
print "not device_exist()"
|
||||
print("not device_exist()")
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -408,29 +408,29 @@ def do_sonic_platform_install():
|
||||
if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3):
|
||||
status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1)
|
||||
if status:
|
||||
print "Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
return status
|
||||
else:
|
||||
print "Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
else:
|
||||
print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
else:
|
||||
print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
def do_sonic_platform_clean():
|
||||
status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0)
|
||||
if status:
|
||||
print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
else:
|
||||
status, output = log_os_system("pip3 uninstall sonic-platform -y", 0)
|
||||
if status:
|
||||
print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
return status
|
||||
else:
|
||||
print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
@ -442,14 +442,14 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + " drivers detected...."
|
||||
print(PROJECT_NAME.upper() + " drivers detected....")
|
||||
if not device_exist():
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + " devices detected...."
|
||||
print(PROJECT_NAME.upper() + " devices detected....")
|
||||
|
||||
for i in range(len(cpld_set)):
|
||||
status, output = log_os_system(cpld_set[i], 1)
|
||||
@ -464,18 +464,18 @@ def do_install():
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() + " has no device installed...."
|
||||
print(PROJECT_NAME.upper() + " has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted() == False:
|
||||
print PROJECT_NAME.upper() + " has no driver installed...."
|
||||
print(PROJECT_NAME.upper() + " has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -533,11 +533,11 @@ def devices_info():
|
||||
# show dict all in the order
|
||||
if DEBUG:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i + ": ")
|
||||
print((i + ": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" " + j)
|
||||
print((" " + j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" " + " " + k)
|
||||
print((" " + " " + k))
|
||||
return
|
||||
|
||||
|
||||
@ -561,15 +561,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
print "node=%s" % node
|
||||
print node + ":"
|
||||
print("node=%s" % node)
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat " + node + "| " + hex_cmd + " -C", 1)
|
||||
if ret == 0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
|
||||
@ -604,10 +604,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat " + node, 1)
|
||||
if ret == 0:
|
||||
print ("Previous fan duty: " + log.strip() + "%")
|
||||
print(("Previous fan duty: " + log.strip() + "%"))
|
||||
ret, log = log_os_system("echo " + args[1] + " >" + node, 1)
|
||||
if ret == 0:
|
||||
print ("Current fan duty: " + args[1] + "%")
|
||||
print(("Current fan duty: " + args[1] + "%"))
|
||||
return ret
|
||||
elif args[0] == 'sfp':
|
||||
if int(args[1]) > DEVICE_NO[args[0]] or int(args[1]) == 0:
|
||||
@ -650,24 +650,24 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper() + ": ")
|
||||
print((i.upper() + ": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " " + j + ":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" " + j + ":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat " + k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j + '_', '', func, 1)
|
||||
func = re.sub(i.lower() + '_', '', func, 1)
|
||||
if ret == 0:
|
||||
print func + "=" + log + " ",
|
||||
print(func + "=" + log + " ", end=' ')
|
||||
else:
|
||||
print func + "=" + "X" + " ",
|
||||
print
|
||||
print(func + "=" + "X" + " ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
|
||||
|
@ -173,11 +173,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
"""
|
||||
|
||||
import os
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -145,8 +145,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -162,9 +162,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -204,39 +204,39 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-48 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-48 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -318,7 +318,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -329,7 +329,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -339,12 +339,12 @@ def device_install():
|
||||
else:
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
status, output =log_os_system("echo port"+str(i)+" > /sys/bus/i2c/devices/"+str(sfp_map[i])+"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -357,7 +357,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -374,7 +374,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -388,40 +388,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_inserted() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -474,11 +474,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -501,15 +501,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
|
||||
@ -576,10 +576,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
#if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -630,36 +630,36 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
if i == 'sfp':
|
||||
port_index = int(filter(str.isdigit, j))
|
||||
port_index = int(list(filter(str.isdigit, j)))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
if k.find('tx_disable')!= -1:
|
||||
ret, k = get_path_sfp_tx_dis(port_index)
|
||||
if ret == False:
|
||||
continue
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print(log, end=' ')
|
||||
if k.find('present')!= -1:
|
||||
ret, k = get_path_sfp_presence(port_index)
|
||||
if ret == False:
|
||||
continue
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print(log, end=' ')
|
||||
|
||||
else:
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print
|
||||
print(log, end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -181,11 +181,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl')
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d'):
|
||||
log_console = 1
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -53,8 +53,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -70,9 +70,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -112,36 +112,36 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-6 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-6 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ROY]"+txt
|
||||
print("[ROY]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -270,7 +270,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -281,13 +281,13 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -305,7 +305,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -321,7 +321,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -335,40 +335,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -421,11 +421,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -448,15 +448,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -490,10 +490,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -533,25 +533,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -181,11 +181,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl')
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d'):
|
||||
log_console = 1
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
"""
|
||||
|
||||
import os
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -145,8 +145,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -162,9 +162,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -204,39 +204,39 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-48 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-48 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -320,7 +320,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -331,7 +331,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -341,12 +341,12 @@ def device_install():
|
||||
else:
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
status, output =log_os_system("echo port"+str(i)+" > /sys/bus/i2c/devices/"+str(sfp_map[i])+"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -359,7 +359,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -376,7 +376,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -390,40 +390,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_inserted() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -476,11 +476,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -503,15 +503,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
|
||||
@ -578,10 +578,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
#if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -632,36 +632,36 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
if i == 'sfp':
|
||||
port_index = int(filter(str.isdigit, j))
|
||||
port_index = int(list(filter(str.isdigit, j)))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
if k.find('tx_disable')!= -1:
|
||||
ret, k = get_path_sfp_tx_dis(port_index)
|
||||
if ret == False:
|
||||
continue
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print(log, end=' ')
|
||||
if k.find('present')!= -1:
|
||||
ret, k = get_path_sfp_presence(port_index)
|
||||
if ret == False:
|
||||
continue
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print(log, end=' ')
|
||||
|
||||
else:
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
log = print_1_device_traversal(i, j, k)
|
||||
print log,
|
||||
print
|
||||
print(log, end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -185,7 +185,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -197,7 +197,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
fan_file.write(str(val))
|
||||
fan_file.close()
|
||||
|
@ -26,7 +26,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
@ -83,7 +83,7 @@ class ThermalUtil(object):
|
||||
return int(content)
|
||||
|
||||
else:
|
||||
print "No such device_path=%s"%device_path
|
||||
print("No such device_path=%s"%device_path)
|
||||
return 0
|
||||
|
||||
def get_num_thermals(self):
|
||||
@ -115,10 +115,10 @@ class ThermalUtil(object):
|
||||
|
||||
def main():
|
||||
thermal = ThermalUtil()
|
||||
print "termal1=%d" %thermal._get_thermal_val(1)
|
||||
print "termal2=%d" %thermal._get_thermal_val(2)
|
||||
print "termal3=%d" %thermal._get_thermal_val(3)
|
||||
print "termal4=%d" %thermal._get_thermal_val(4)
|
||||
print("termal1=%d" %thermal._get_thermal_val(1))
|
||||
print("termal2=%d" %thermal._get_thermal_val(2))
|
||||
print("termal3=%d" %thermal._get_thermal_val(3))
|
||||
print("termal4=%d" %thermal._get_thermal_val(4))
|
||||
#
|
||||
# print 'get_size_node_map : %d' % thermal.get_size_node_map()
|
||||
# print 'get_size_path_map : %d' % thermal.get_size_path_map()
|
||||
|
@ -176,11 +176,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -132,7 +132,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -151,7 +151,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -173,11 +173,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -138,7 +138,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -164,11 +164,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -53,8 +53,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -70,9 +70,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -112,36 +112,36 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 49-54 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 49-54 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[Debug]"+txt
|
||||
print("[Debug]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -277,7 +277,7 @@ def device_install():
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
time.sleep(0.01)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -288,7 +288,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(49, 55): #Set qsfp port to normal state
|
||||
@ -297,13 +297,13 @@ def device_install():
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
path = "/sys/bus/i2c/devices/{0}-0050/port_name"
|
||||
status, output =log_os_system("echo port{0} > ".format(i+49)+path.format(sfp_map[i]), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -321,7 +321,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -337,7 +337,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -351,40 +351,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -437,11 +437,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -464,15 +464,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -506,10 +506,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -549,25 +549,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -185,7 +185,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -197,7 +197,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
fan_file.write(str(val))
|
||||
fan_file.close()
|
||||
|
@ -26,7 +26,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
@ -83,7 +83,7 @@ class ThermalUtil(object):
|
||||
return int(content)
|
||||
|
||||
else:
|
||||
print "No such device_path=%s"%device_path
|
||||
print("No such device_path=%s"%device_path)
|
||||
return 0
|
||||
|
||||
def get_num_thermals(self):
|
||||
@ -115,10 +115,10 @@ class ThermalUtil(object):
|
||||
|
||||
def main():
|
||||
thermal = ThermalUtil()
|
||||
print "termal1=%d" %thermal._get_thermal_val(1)
|
||||
print "termal2=%d" %thermal._get_thermal_val(2)
|
||||
print "termal3=%d" %thermal._get_thermal_val(3)
|
||||
print "termal4=%d" %thermal._get_thermal_val(4)
|
||||
print("termal1=%d" %thermal._get_thermal_val(1))
|
||||
print("termal2=%d" %thermal._get_thermal_val(2))
|
||||
print("termal3=%d" %thermal._get_thermal_val(3))
|
||||
print("termal4=%d" %thermal._get_thermal_val(4))
|
||||
#
|
||||
# print 'get_size_node_map : %d' % thermal.get_size_node_map()
|
||||
# print 'get_size_path_map : %d' % thermal.get_size_path_map()
|
||||
|
@ -175,11 +175,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -132,7 +132,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -151,7 +151,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -173,11 +173,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -138,7 +138,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -164,11 +164,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -48,8 +48,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print(sys.argv[0])
|
||||
print("ARGV :", sys.argv[1:])
|
||||
print((sys.argv[0]))
|
||||
print(("ARGV :", sys.argv[1:]))
|
||||
|
||||
|
||||
def main():
|
||||
@ -67,7 +67,7 @@ def main():
|
||||
if DEBUG == True:
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
print((len(sys.argv)))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -96,13 +96,13 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
print((__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print("[Debug]"+txt)
|
||||
print(("[Debug]"+txt))
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
@ -113,7 +113,7 @@ def log_os_system(cmd, show):
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -348,29 +348,29 @@ def do_sonic_platform_install():
|
||||
if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3):
|
||||
status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1)
|
||||
if status:
|
||||
print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3) )
|
||||
print(("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3) ))
|
||||
return status
|
||||
else:
|
||||
print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3) )
|
||||
print(("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3) ))
|
||||
else:
|
||||
print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
else:
|
||||
print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
def do_sonic_platform_clean():
|
||||
status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0)
|
||||
if status:
|
||||
print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
else:
|
||||
status, output = log_os_system("pip3 uninstall sonic-platform -y", 0)
|
||||
if status:
|
||||
print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
return status
|
||||
else:
|
||||
print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
@ -383,7 +383,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
print((PROJECT_NAME.upper()+" drivers detected...."))
|
||||
if not device_exist():
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
@ -391,7 +391,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
print((PROJECT_NAME.upper()+" devices detected...."))
|
||||
|
||||
do_sonic_platform_install()
|
||||
|
||||
@ -400,7 +400,7 @@ def do_install():
|
||||
def do_uninstall():
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
print((PROJECT_NAME.upper() +" has no device installed...."))
|
||||
else:
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
@ -409,7 +409,7 @@ def do_uninstall():
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
print((PROJECT_NAME.upper() +" has no driver installed...."))
|
||||
else:
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
|
@ -193,7 +193,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -212,7 +212,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
||||
fan_file.write(str(val))
|
||||
|
@ -180,11 +180,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -37,7 +37,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -153,8 +153,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -170,9 +170,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -213,39 +213,39 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -332,7 +332,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -343,19 +343,19 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
status, output =log_os_system("echo port"+str(i)+" > /sys/bus/i2c/devices/"+str(sfp_map[i])+"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -374,7 +374,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -390,7 +390,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -404,40 +404,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_inserted() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -494,11 +494,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -521,15 +521,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -563,10 +563,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -606,25 +606,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -179,7 +179,7 @@ class FanUtil(object):
|
||||
with open(self.FAN_DUTY_PATH) as val_file:
|
||||
content = val_file.readline().rstrip()
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
return int(content)
|
||||
|
||||
@ -188,7 +188,7 @@ class FanUtil(object):
|
||||
with open(self.FAN_DUTY_PATH, 'r+') as val_file:
|
||||
val_file.write(str(val))
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -192,11 +192,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -29,7 +29,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -56,8 +56,8 @@ FORCE = 0
|
||||
# logging.basicConfig(level=logging.INFO)
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -71,9 +71,9 @@ def main():
|
||||
(options, ARGS) = getopt.getopt(sys.argv[1:], 'hdf',
|
||||
['help','debug', 'force'])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print ARGS
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(ARGS)
|
||||
print(len(sys.argv))
|
||||
|
||||
for (opt, arg) in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -116,40 +116,40 @@ def main():
|
||||
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName': sys.argv[0].split('/')[-1]}
|
||||
print(__doc__ % {'scriptName': sys.argv[0].split('/')[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split('/')[-1] + ' ' + ARGS[0]
|
||||
print cmd + ' [led|sfp|fan]'
|
||||
print ' use "' + cmd + ' led 0-4 " to set led color'
|
||||
print ' use "' + cmd + ' fan 0-100" to set fan duty percetage'
|
||||
print ' use "' + cmd + ' sfp 1-48 {0|1}" to set sfp# tx_disable'
|
||||
print(cmd + ' [led|sfp|fan]')
|
||||
print(' use "' + cmd + ' led 0-4 " to set led color')
|
||||
print(' use "' + cmd + ' fan 0-100" to set fan duty percetage')
|
||||
print(' use "' + cmd + ' sfp 1-48 {0|1}" to set sfp# tx_disable')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split('/')[-1] + ' ' + ARGS[0]
|
||||
print ' use "' + cmd + ' 1-54 " to dump sfp# eeprom'
|
||||
print(' use "' + cmd + ' 1-54 " to dump sfp# eeprom')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print '[DBG]' + txt
|
||||
print('[DBG]' + txt)
|
||||
return
|
||||
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :' + cmd)
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
(status, output) = subprocess.getstatusoutput(cmd)
|
||||
my_log(cmd + 'with result:' + str(status))
|
||||
my_log(' output:' + output)
|
||||
if status:
|
||||
logging.info('Failed :' + cmd)
|
||||
if show:
|
||||
print 'Failed :' + cmd
|
||||
print('Failed :' + cmd)
|
||||
return (status, output)
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ def device_install():
|
||||
|
||||
(status, output) = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -305,7 +305,7 @@ def device_install():
|
||||
|
||||
(status, output) = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(0, len(sfp_map)):
|
||||
@ -318,7 +318,7 @@ def device_install():
|
||||
log_os_system('echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-'
|
||||
+ str(sfp_map[i]) + '/new_device', 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -331,7 +331,7 @@ def device_uninstall():
|
||||
+ '/delete_device'
|
||||
(status, output) = log_os_system('echo 0x50 > ' + target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -348,7 +348,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
(status, output) = log_os_system(' '.join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -374,69 +374,69 @@ def do_sonic_platform_install():
|
||||
if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3):
|
||||
status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1)
|
||||
if status:
|
||||
print "Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
return status
|
||||
else:
|
||||
print "Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
else:
|
||||
print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
else:
|
||||
print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
def do_sonic_platform_clean():
|
||||
status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0)
|
||||
if status:
|
||||
print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
else:
|
||||
status, output = log_os_system("pip3 uninstall sonic-platform -y", 0)
|
||||
if status:
|
||||
print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
return status
|
||||
else:
|
||||
print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
def do_install():
|
||||
print 'Checking system....'
|
||||
print('Checking system....')
|
||||
if driver_check() is False:
|
||||
print 'No driver, installing....'
|
||||
print('No driver, installing....')
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + ' drivers detected....'
|
||||
print(PROJECT_NAME.upper() + ' drivers detected....')
|
||||
if not device_exist():
|
||||
print 'No device, installing....'
|
||||
print('No device, installing....')
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + ' devices detected....'
|
||||
print(PROJECT_NAME.upper() + ' devices detected....')
|
||||
do_sonic_platform_install()
|
||||
|
||||
return
|
||||
|
||||
|
||||
def do_uninstall():
|
||||
print 'Checking system....'
|
||||
print('Checking system....')
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() + ' has no device installed....'
|
||||
print(PROJECT_NAME.upper() + ' has no device installed....')
|
||||
else:
|
||||
print 'Removing device....'
|
||||
print('Removing device....')
|
||||
status = device_uninstall()
|
||||
if status and FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check() is False:
|
||||
print PROJECT_NAME.upper() + ' has no driver installed....'
|
||||
print(PROJECT_NAME.upper() + ' has no driver installed....')
|
||||
else:
|
||||
print 'Removing installed driver....'
|
||||
print('Removing installed driver....')
|
||||
status = driver_uninstall()
|
||||
if status and FORCE == 0:
|
||||
return status
|
||||
@ -496,11 +496,11 @@ def devices_info():
|
||||
# show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print i + ': '
|
||||
print(i + ': ')
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print ' ' + j
|
||||
print(' ' + j)
|
||||
for k in ALL_DEVICE[i][j]:
|
||||
print ' ' + ' ' + k
|
||||
print(' ' + ' ' + k)
|
||||
return
|
||||
|
||||
|
||||
@ -525,14 +525,14 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ':'
|
||||
print(node + ':')
|
||||
(ret, log) = log_os_system('cat ' + node + '| ' + hex_cmd + ' -C',
|
||||
1)
|
||||
if ret == 0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print( '**********device no found**********')
|
||||
return
|
||||
@ -573,10 +573,10 @@ def set_device(args):
|
||||
'fan_duty_cycle_percentage')
|
||||
(ret, log) = log_os_system('cat ' + node, 1)
|
||||
if ret == 0:
|
||||
print 'Previous fan duty: ' + log.strip() + '%'
|
||||
print('Previous fan duty: ' + log.strip() + '%')
|
||||
ret = log_os_system('echo ' + args[1] + ' >' + node, 1)
|
||||
if ret[0] == 0:
|
||||
print 'Current fan duty: ' + args[1] + '%'
|
||||
print('Current fan duty: ' + args[1] + '%')
|
||||
return ret
|
||||
elif args[0] == 'sfp':
|
||||
if int(args[1]) > qsfp_start or int(args[1]) == 0:
|
||||
@ -611,30 +611,30 @@ def get_value(i):
|
||||
|
||||
def device_traversal():
|
||||
if system_ready() is False:
|
||||
print "System is not ready."
|
||||
print 'Please install first!'
|
||||
print("System is not ready.")
|
||||
print('Please install first!')
|
||||
return
|
||||
|
||||
if not ALL_DEVICE:
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print '============================================'
|
||||
print i.upper() + ': '
|
||||
print '============================================'
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print ' ' + j + ':',
|
||||
print('============================================')
|
||||
print(i.upper() + ': ')
|
||||
print('============================================')
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(' ' + j + ':', end=' ')
|
||||
for k in ALL_DEVICE[i][j]:
|
||||
(ret, log) = log_os_system('cat ' + k, 0)
|
||||
func = k.split('/')[-1].strip()
|
||||
func = re.sub(j + '_', '', func, 1)
|
||||
func = re.sub(i.lower() + '_', '', func, 1)
|
||||
if ret == 0:
|
||||
print func + '=' + log + ' ',
|
||||
print(func + '=' + log + ' ', end=' ')
|
||||
else:
|
||||
print func + '=' + 'X' + ' ',
|
||||
print
|
||||
print '----------------------------------------------------------------'
|
||||
print
|
||||
print(func + '=' + 'X' + ' ', end=' ')
|
||||
print()
|
||||
print('----------------------------------------------------------------')
|
||||
print()
|
||||
return
|
||||
|
||||
|
||||
|
@ -200,7 +200,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -219,7 +219,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
||||
fan_file.write(str(val))
|
||||
|
@ -193,11 +193,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl')
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d]' % sys.argv[0]
|
||||
print('Usage: %s [-d]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d'):
|
||||
log_console = 1
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -53,8 +53,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -70,9 +70,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -112,36 +112,36 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-54 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-54 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ROY]"+txt
|
||||
print("[ROY]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -292,7 +292,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -303,7 +303,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(0,len(sfp_map)):
|
||||
@ -312,7 +312,7 @@ def device_install():
|
||||
else:
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -330,7 +330,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -346,7 +346,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -360,40 +360,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -446,11 +446,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -473,15 +473,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -515,10 +515,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -558,25 +558,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -168,7 +168,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH.format(1))
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -180,7 +180,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH.format(fan_num), 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
fan_file.write(str(val))
|
||||
fan_file.close()
|
||||
|
@ -138,11 +138,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl')
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d'):
|
||||
log_console = 1
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -55,8 +55,8 @@ qsfp_start_index = 24
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -72,9 +72,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -114,36 +114,36 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-1 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-27 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-1 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-27 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-27 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-27 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ROY]"+txt
|
||||
print("[ROY]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -251,7 +251,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -262,7 +262,7 @@ def device_install():
|
||||
else:
|
||||
status, output =log_os_system("echo optoe2 0x50 > " + path, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -276,7 +276,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -289,7 +289,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -303,41 +303,41 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -395,11 +395,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -420,15 +420,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system(hex_cmd +" -C "+node, 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -462,10 +462,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -505,25 +505,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -193,7 +193,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -212,7 +212,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
fan_file.write(str(val))
|
||||
fan_file.close()
|
||||
|
@ -27,7 +27,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
@ -37,14 +37,14 @@ def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
if show:
|
||||
print "ACC: " + str(cmd) + " , result:"+ str(status)
|
||||
print("ACC: " + str(cmd) + " , result:"+ str(status))
|
||||
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ class ThermalUtil(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return 0
|
||||
file_str = check_file.read()
|
||||
search_str="average current temperature is"
|
||||
|
@ -282,11 +282,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -295,7 +295,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1]== '-t':
|
||||
if len(sys.argv)!=8:
|
||||
print "temp test, need input six temp"
|
||||
print("temp test, need input six temp")
|
||||
return 0
|
||||
|
||||
i=0
|
||||
@ -304,11 +304,11 @@ def main(argv):
|
||||
i=i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(38)
|
||||
print "set default fan speed to 37.5%"
|
||||
print("set default fan speed to 37.5%")
|
||||
monitor = device_monitor(log_file, log_level)
|
||||
# Loop forever, doing something useful hopefully:
|
||||
while True:
|
||||
|
@ -133,7 +133,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -152,7 +152,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -174,11 +174,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -138,7 +138,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -164,11 +164,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -268,11 +268,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdlt:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
print(('Usage: %s [-d] [-l <log_file>]' % sys.argv[0]))
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
print(('Usage: %s [-d] [-l <log_file>]' % sys.argv[0]))
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -39,7 +39,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -62,8 +62,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -79,9 +79,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -121,28 +121,28 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-56 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-56 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def dis_i2c_ir3570a(addr):
|
||||
cmd = "i2cset -y 0 0x%x 0xE5 0x01" % addr
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
cmd = "i2cset -y 0 0x%x 0x12 0x02" % addr
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
return status
|
||||
|
||||
def ir3570_check():
|
||||
cmd = "i2cdump -y 0 0x42 s 0x9a"
|
||||
try:
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
lines = output.split('\n')
|
||||
hn = re.findall(r'\w+', lines[-1])
|
||||
version = int(hn[1], 16)
|
||||
@ -151,30 +151,30 @@ def ir3570_check():
|
||||
else:
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
print "Error on ir3570_check() e:" + str(e)
|
||||
print("Error on ir3570_check() e:" + str(e))
|
||||
return -1
|
||||
return ret
|
||||
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-56 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-56 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ROY]"+txt
|
||||
print("[ROY]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -306,7 +306,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -317,7 +317,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(0,len(sfp_map)):
|
||||
@ -326,7 +326,7 @@ def device_install():
|
||||
else:
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -344,7 +344,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -360,7 +360,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -374,43 +374,43 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
|
||||
ir3570_check()
|
||||
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -466,11 +466,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -493,15 +493,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -535,10 +535,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -577,24 +577,24 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -2,91 +2,91 @@
|
||||
# Script to stop and start the respective platforms default services.
|
||||
# This will be used while switching the pddf->non-pddf mode and vice versa
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
|
||||
def check_pddf_support():
|
||||
return True
|
||||
|
||||
def stop_platform_svc():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7326-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-fan.service failed %d"%status
|
||||
print("Stop as7326-platform-fan.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7326-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-psu.service failed %d"%status
|
||||
print("Stop as7326-platform-psu.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-init.service failed %d"%status
|
||||
print("Stop as7326-platform-init.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7326-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Disable as7326-platform-monitor.service failed %d"%status
|
||||
print("Disable as7326-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7326_util.py clean")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7326_util.py clean")
|
||||
if status:
|
||||
print "accton_as7326_util.py clean command failed %d"%status
|
||||
print("accton_as7326_util.py clean command failed %d"%status)
|
||||
return False
|
||||
|
||||
# HACK , stop the pddf-platform-init service if it is active
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service along with other platform serives failed %d"%status
|
||||
print("Stop pddf-platform-init.service along with other platform serives failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_svc():
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7326_util.py install")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7326_util.py install")
|
||||
if status:
|
||||
print "accton_as7326_util.py install command failed %d"%status
|
||||
print("accton_as7326_util.py install command failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl enable as7326-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Enable as7326-platform-monitor.service failed %d"%status
|
||||
print("Enable as7326-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as7326-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as7326-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Start as7326-platform-monitor-fan.service failed %d"%status
|
||||
print("Start as7326-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl start as7326-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as7326-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Start as7326-platform-monitor-psu.service failed %d"%status
|
||||
print("Start as7326-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
if status:
|
||||
print "Start pddf-platform-init.service failed %d"%status
|
||||
print("Start pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def stop_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service failed %d"%status
|
||||
print("Stop pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def main():
|
||||
print"stop_platform_svc"
|
||||
print("stop_platform_svc")
|
||||
stop_platform_svc()
|
||||
#print"start_platform_svc"
|
||||
#start_platform_svc()
|
||||
#print"start_platform_pddf"
|
||||
#start_platform_pddf()
|
||||
print"stop_platform_pddf"
|
||||
print("stop_platform_pddf")
|
||||
stop_platform_pddf()
|
||||
#pass
|
||||
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -53,8 +53,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -70,9 +70,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -112,36 +112,36 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ROY]"+txt
|
||||
print("[ROY]"+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -276,7 +276,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod2[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
@ -287,13 +287,13 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -311,7 +311,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -327,7 +327,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -341,40 +341,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_check() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -427,11 +427,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -454,15 +454,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -496,10 +496,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -539,25 +539,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -194,7 +194,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -213,7 +213,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
||||
fan_file.write(str(val))
|
||||
|
@ -179,11 +179,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -149,8 +149,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -166,9 +166,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -208,28 +208,28 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def dis_i2c_ir3570a(addr):
|
||||
cmd = "i2cset -y 0 0x%x 0xE5 0x01" % addr
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
cmd = "i2cset -y 0 0x%x 0x12 0x02" % addr
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
return status
|
||||
|
||||
def ir3570_check():
|
||||
cmd = "i2cdump -y 0 0x42 s 0x9a"
|
||||
try:
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
lines = output.split('\n')
|
||||
hn = re.findall(r'\w+', lines[-1])
|
||||
version = int(hn[1], 16)
|
||||
@ -238,32 +238,32 @@ def ir3570_check():
|
||||
else:
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
print "Error on ir3570_check() e:" + str(e)
|
||||
print("Error on ir3570_check() e:" + str(e))
|
||||
return -1
|
||||
return ret
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -341,19 +341,19 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
status, output =log_os_system("echo port"+str(i)+" > /sys/bus/i2c/devices/"+str(sfp_map[i])+"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
@ -371,7 +371,7 @@ def device_uninstall():
|
||||
target = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/delete_device"
|
||||
status, output =log_os_system("echo 0x50 > "+ target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -387,7 +387,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -397,7 +397,7 @@ def system_ready():
|
||||
if driver_inserted() == False:
|
||||
return False
|
||||
if not device_exist():
|
||||
print "not device_exist()"
|
||||
print("not device_exist()")
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -408,7 +408,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
|
||||
ir3570_check()
|
||||
|
||||
@ -418,23 +418,23 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -487,11 +487,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -514,15 +514,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -556,10 +556,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -599,25 +599,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -202,7 +202,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -221,7 +221,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
||||
fan_file.write(str(val))
|
||||
@ -237,7 +237,7 @@ class FanUtil(object):
|
||||
def get_fan_status(self, fan_num):
|
||||
if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD:
|
||||
logging.debug('GET. Parameter error. fan_num, %d', fan_num)
|
||||
print "fan %d return none" %fan_num
|
||||
print("fan %d return none" %fan_num)
|
||||
return None
|
||||
|
||||
if self.get_fan_fault(fan_num) is not None and self.get_fan_fault(fan_num) > 0:
|
||||
|
@ -27,7 +27,7 @@ try:
|
||||
import logging
|
||||
import logging.config
|
||||
import time # this is only being used as part of the example
|
||||
import commands
|
||||
import subprocess
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
|
||||
@ -41,25 +41,25 @@ global log_level
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
if DEBUG == True:
|
||||
my_log (cmd +" , result:" + str(status))
|
||||
else:
|
||||
if show:
|
||||
print "ACC: " + str(cmd) + " , result:"+ str(status)
|
||||
print("ACC: " + str(cmd) + " , result:"+ str(status))
|
||||
#my_log ("cmd:" + cmd)
|
||||
#my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
|
||||
def manage_ipmi_qsfp(self):
|
||||
logging.debug ("drv hanlder-manage_ipmi_qsfp")
|
||||
print "drv hanlder"
|
||||
print("drv hanlder")
|
||||
#Handle QSFP case
|
||||
ipmi_cmd = self.IPMI_CMD_QSFP + " 0x10 > " +self.QSFP_PRESENT_FILE
|
||||
log_os_system(ipmi_cmd, 0)
|
||||
@ -129,7 +129,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
pres_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -158,7 +158,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -170,7 +170,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line+= line.rstrip().replace(" ","")
|
||||
|
||||
@ -209,7 +209,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -244,7 +244,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -293,7 +293,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -366,7 +366,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -379,7 +379,7 @@ class accton_as7716xb_drv_handler(object):
|
||||
try:
|
||||
check_file = open(file_path)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
line = check_file.readline()
|
||||
str_line+= line.rstrip().replace(" ","")
|
||||
while line:
|
||||
@ -401,11 +401,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -199,11 +199,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -30,7 +30,7 @@ command:
|
||||
set : change board setting with fan|led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -145,8 +145,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -162,9 +162,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -204,39 +204,39 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp|fan]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp|fan]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -316,22 +316,22 @@ def device_install():
|
||||
# if FORCE == 0:
|
||||
# return status
|
||||
#else:
|
||||
print "Prepar to create instance.............."
|
||||
print("Prepar to create instance..............")
|
||||
for i in range(0,len(mknod_xb)):
|
||||
print "Beginn to create instance.............."
|
||||
print("Beginn to create instance..............")
|
||||
status, output = log_os_system(mknod_xb[i], 1)
|
||||
print "status=%s" %status
|
||||
print "output=%s" %output
|
||||
print("status=%s" %status)
|
||||
print("output=%s" %output)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
#time.sleep (50.0 / 1000.0)
|
||||
print "Create sfp instance.............."
|
||||
print("Create sfp instance..............")
|
||||
for i in range(0,len(sfp_map)):
|
||||
status, output =log_os_system("echo as7716_32xb_oom 0x"+str(sfp_map[i])+ " > /sys/bus/i2c/devices/i2c-0/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
#status, output =log_os_system("echo port"+str(i)+" > /sys/bus/i2c/devices/0-000"+str(sfp_map[i])+"/port_name", 1)
|
||||
@ -349,7 +349,7 @@ def device_uninstall():
|
||||
print(target)
|
||||
status, output =log_os_system(target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -362,7 +362,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -370,48 +370,48 @@ def device_uninstall():
|
||||
|
||||
def system_ready():
|
||||
if driver_inserted() == False:
|
||||
print "driver_inserted() == False"
|
||||
print("driver_inserted() == False")
|
||||
return False
|
||||
if not device_exist():
|
||||
print "not device_exist()"
|
||||
print("not device_exist()")
|
||||
return False
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_inserted() == False:
|
||||
print "No driver, installing.1..."
|
||||
print("No driver, installing.1...")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing..2.."
|
||||
print("No device, installing..2..")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking systemm...."
|
||||
print("Checking systemm....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -443,13 +443,13 @@ def devices_info():
|
||||
for k in range(0,DEVICE_NO[key]):
|
||||
node = key+str(k+1)
|
||||
path = i2c_prefix+ str(sfp_map[k])+ buses[i]+"/"+ nodes[j]
|
||||
print "path= %s" %path
|
||||
print "i=%d" %i
|
||||
print "k=%d" %k
|
||||
print "j= %d" %j
|
||||
print "sfp_map[k]=%s" %sfp_map[k]
|
||||
print " buses[i]=%s" %buses[i]
|
||||
print "nodes[j]=%s" %nodes[j]
|
||||
print("path= %s" %path)
|
||||
print("i=%d" %i)
|
||||
print("k=%d" %k)
|
||||
print("j= %d" %j)
|
||||
print("sfp_map[k]=%s" %sfp_map[k])
|
||||
print(" buses[i]=%s" %buses[i])
|
||||
print("nodes[j]=%s" %nodes[j])
|
||||
my_log(node+": "+ path)
|
||||
ALL_DEVICE[key][node].append(path)
|
||||
else:
|
||||
@ -471,11 +471,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -498,15 +498,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -540,10 +540,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat "+ node, 1)
|
||||
if ret==0:
|
||||
print ("Previous fan duty: " + log.strip() +"%")
|
||||
print(("Previous fan duty: " + log.strip() +"%"))
|
||||
ret, log = log_os_system("echo "+args[1]+" >"+node, 1)
|
||||
if ret==0:
|
||||
print ("Current fan duty: " + args[1] +"%")
|
||||
print(("Current fan duty: " + args[1] +"%"))
|
||||
return ret
|
||||
elif args[0]=='sfp':
|
||||
if int(args[1])> DEVICE_NO[args[0]] or int(args[1])==0:
|
||||
@ -583,25 +583,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -191,7 +191,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -210,7 +210,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
#val = ((val + 1 ) * 625 +75 ) / 100
|
||||
fan_file.write(str(val))
|
||||
|
@ -28,7 +28,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
|
@ -291,11 +291,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -304,7 +304,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1]== '-t':
|
||||
if len(sys.argv)!=7:
|
||||
print "temp test, need input six temp"
|
||||
print("temp test, need input six temp")
|
||||
return 0
|
||||
|
||||
i=0
|
||||
@ -313,11 +313,11 @@ def main(argv):
|
||||
i=i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(38)
|
||||
print "set default fan speed to 37.5%"
|
||||
print("set default fan speed to 37.5%")
|
||||
monitor = device_monitor(log_file, log_level)
|
||||
# Loop forever, doing something useful hopefully:
|
||||
while True:
|
||||
|
@ -130,7 +130,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -149,7 +149,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -171,11 +171,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -96,7 +96,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -143,11 +143,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -279,11 +279,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
print(('Usage: %s [-d] [-l <log_file>]' % sys.argv[0]))
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
print(('Usage: %s [-d] [-l <log_file>]' % sys.argv[0]))
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -100,8 +100,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
print((sys.argv[0]))
|
||||
print(('ARGV :', sys.argv[1:]))
|
||||
|
||||
|
||||
def main():
|
||||
@ -119,7 +119,7 @@ def main():
|
||||
if DEBUG == True:
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
print((len(sys.argv)))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -143,7 +143,7 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
print(( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}))
|
||||
sys.exit(0)
|
||||
|
||||
def dis_i2c_ir3570a(addr):
|
||||
@ -165,14 +165,14 @@ def ir3570_check():
|
||||
else:
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
print( "Error on ir3570_check() e:" + str(e))
|
||||
print(( "Error on ir3570_check() e:" + str(e)))
|
||||
return -1
|
||||
return ret
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print("[ACCTON DBG]: ",txt)
|
||||
print(("[ACCTON DBG]: ",txt))
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
@ -186,7 +186,7 @@ def log_os_system(cmd, show):
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -325,7 +325,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
print((PROJECT_NAME.upper()+" drivers detected...."))
|
||||
|
||||
ir3570_check()
|
||||
|
||||
@ -335,12 +335,12 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
print((PROJECT_NAME.upper()+" devices detected...."))
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print(PROJECT_NAME.upper()+" has no device installed....")
|
||||
print((PROJECT_NAME.upper()+" has no device installed...."))
|
||||
else:
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
@ -349,7 +349,7 @@ def do_uninstall():
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print(PROJECT_NAME.upper()+" has no driver installed....")
|
||||
print((PROJECT_NAME.upper()+" has no driver installed...."))
|
||||
else:
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
|
@ -2,95 +2,95 @@
|
||||
# Script to stop and start the respective platforms default services.
|
||||
# This will be used while switching the pddf->non-pddf mode and vice versa
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
|
||||
def check_pddf_support():
|
||||
return True
|
||||
|
||||
def stop_platform_svc():
|
||||
status, output = commands.getstatusoutput("systemctl stop as7726-32x-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7726-32x-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Stop as7726-32x-platform-monitor-fan.service failed %d"%status
|
||||
print("Stop as7726-32x-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7726-32x-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as7726-32x-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Disable as7726-32x-platform-monitor-fan.service failed %d"%status
|
||||
print("Disable as7726-32x-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl stop as7726-32x-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7726-32x-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Stop as7726-32x-platform-monitor-psu.service failed %d"%status
|
||||
print("Stop as7726-32x-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7726-32x-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as7726-32x-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Disable as7726-32x-platform-monitor-psu.service failed %d"%status
|
||||
print("Disable as7726-32x-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl stop as7726-32x-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7726-32x-platform-monitor.service")
|
||||
if status:
|
||||
print "Stop as7726-32x-platform-monitor.service failed %d"%status
|
||||
print("Stop as7726-32x-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7726-32x-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as7726-32x-platform-monitor.service")
|
||||
if status:
|
||||
print "Disable as7726-32x-platform-monitor.service failed %d"%status
|
||||
print("Disable as7726-32x-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7726_32x_util.py clean")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7726_32x_util.py clean")
|
||||
if status:
|
||||
print "accton_as7726_32x_util.py clean command failed %d"%status
|
||||
print("accton_as7726_32x_util.py clean command failed %d"%status)
|
||||
return False
|
||||
|
||||
# HACK , stop the pddf-platform-init service if it is active
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service along with other platform serives failed %d"%status
|
||||
print("Stop pddf-platform-init.service along with other platform serives failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_svc():
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7726_32x_util.py install")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7726_32x_util.py install")
|
||||
if status:
|
||||
print "accton_as7726_32x_util.py install command failed %d"%status
|
||||
print("accton_as7726_32x_util.py install command failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl enable as7726-32x-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as7726-32x-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Enable as7726-32x-platform-monitor-fan.service failed %d"%status
|
||||
print("Enable as7726-32x-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as7726-32x-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as7726-32x-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Start as7726-32x-platform-monitor-fan.service failed %d"%status
|
||||
print("Start as7726-32x-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl enable as7726-32x-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as7726-32x-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Enable as7726-32x-platform-monitor-psu.service failed %d"%status
|
||||
print("Enable as7726-32x-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as7726-32x-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as7726-32x-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Start as7726-32x-platform-monitor-psu.service failed %d"%status
|
||||
print("Start as7726-32x-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl enable as7726-32x-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as7726-32x-platform-monitor.service")
|
||||
if status:
|
||||
print "Enable as7726-32x-platform-monitor.service failed %d"%status
|
||||
print("Enable as7726-32x-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as7726-32x-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as7726-32x-platform-monitor.service")
|
||||
if status:
|
||||
print "Start as7726-32x-platform-monitor.service failed %d"%status
|
||||
print("Start as7726-32x-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
if status:
|
||||
print "Start pddf-platform-init.service failed %d"%status
|
||||
print("Start pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def stop_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service failed %d"%status
|
||||
print("Stop pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -185,7 +185,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -204,7 +204,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
fan_file.write(str(val))
|
||||
fan_file.close()
|
||||
|
@ -136,11 +136,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -167,11 +167,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdlt:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print("Usage: %s [-d] [-l <log_file>]" % sys.argv[0])
|
||||
print(("Usage: %s [-d] [-l <log_file>]" % sys.argv[0]))
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print("Usage: %s [-d] [-l <log_file>]" % sys.argv[0])
|
||||
print(("Usage: %s [-d] [-l <log_file>]" % sys.argv[0]))
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -48,8 +48,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:] )
|
||||
print((sys.argv[0]))
|
||||
print(('ARGV :', sys.argv[1:] ))
|
||||
|
||||
|
||||
def main():
|
||||
@ -67,7 +67,7 @@ def main():
|
||||
if DEBUG == True:
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
print((len(sys.argv)))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -91,7 +91,7 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
print(( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}))
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@ -114,13 +114,13 @@ def ir3570_check():
|
||||
else:
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
print("Error on ir3570_check() e:" + str(e))
|
||||
print(("Error on ir3570_check() e:" + str(e)))
|
||||
return -1
|
||||
return ret
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print("[ROY]"+txt)
|
||||
print(("[ROY]"+txt))
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
@ -131,7 +131,7 @@ def log_os_system(cmd, show):
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_check():
|
||||
@ -308,7 +308,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
print((PROJECT_NAME.upper()+" drivers detected...."))
|
||||
|
||||
ir3570_check()
|
||||
|
||||
@ -319,13 +319,13 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
print((PROJECT_NAME.upper()+" devices detected...."))
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
print((PROJECT_NAME.upper() +" has no device installed...."))
|
||||
else:
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
@ -334,7 +334,7 @@ def do_uninstall():
|
||||
return status
|
||||
|
||||
if driver_check()== False :
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
print((PROJECT_NAME.upper() +" has no driver installed...."))
|
||||
else:
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# Script to stop and start the respective platforms default services.
|
||||
# This will be used while switching the pddf->non-pddf mode and vice versa
|
||||
import commands
|
||||
import subprocess
|
||||
|
||||
|
||||
def check_pddf_support():
|
||||
@ -10,56 +10,56 @@ def check_pddf_support():
|
||||
|
||||
def stop_platform_svc():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7816-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as7816-platform-init.service")
|
||||
if status:
|
||||
print("Stop as7816-platform-init.service failed %d" % status)
|
||||
print(("Stop as7816-platform-init.service failed %d" % status))
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7816-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as7816-platform-init.service")
|
||||
if status:
|
||||
print("Disable as7816-platform-init.service failed %d" % status)
|
||||
print(("Disable as7816-platform-init.service failed %d" % status))
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7816_util.py clean")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7816_util.py clean")
|
||||
if status:
|
||||
print("accton_as7816_util.py clean command failed %d" % status)
|
||||
print(("accton_as7816_util.py clean command failed %d" % status))
|
||||
return False
|
||||
|
||||
# HACK , stop the pddf-platform-init service if it is active
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print("Stop pddf-platform-init.service along with other platform serives failed %d" % status)
|
||||
print(("Stop pddf-platform-init.service along with other platform serives failed %d" % status))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def start_platform_svc():
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7816_util.py install")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as7816_util.py install")
|
||||
if status:
|
||||
print("accton_as7816_util.py install command failed %d" % status)
|
||||
print(("accton_as7816_util.py install command failed %d" % status))
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl enable as7816-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as7816-platform-init.service")
|
||||
if status:
|
||||
print("Enable as7816-platform-init.service failed %d" % status)
|
||||
print(("Enable as7816-platform-init.service failed %d" % status))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def start_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
if status:
|
||||
print("Start pddf-platform-init.service failed %d" % status)
|
||||
print(("Start pddf-platform-init.service failed %d" % status))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def stop_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print("Stop pddf-platform-init.service failed %d" % status)
|
||||
print(("Stop pddf-platform-init.service failed %d" % status))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -184,7 +184,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -196,7 +196,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
fan_file.write(str(val))
|
||||
|
@ -24,7 +24,7 @@ try:
|
||||
import time
|
||||
import logging
|
||||
import glob
|
||||
import commands
|
||||
import subprocess
|
||||
from collections import namedtuple
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
|
@ -20,7 +20,7 @@
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt, sys
|
||||
import logging
|
||||
import logging.config
|
||||
@ -184,7 +184,7 @@ class switch(object):
|
||||
|
||||
def power_off_dut():
|
||||
cmd_str="i2cset -y -f 19 0x60 0x60 0x10"
|
||||
status, output = commands.getstatusoutput(cmd_str)
|
||||
status, output = subprocess.getstatusoutput(cmd_str)
|
||||
return status
|
||||
|
||||
#If only one PSU insert(or one of PSU pwoer fail), and watt >800w. Must let DUT fan pwm >= 75% in AFO.
|
||||
@ -493,11 +493,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -506,7 +506,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1]== '-t':
|
||||
if len(sys.argv)!=10:
|
||||
print "temp test, need input 8 temp"
|
||||
print("temp test, need input 8 temp")
|
||||
return 0
|
||||
i=0
|
||||
for x in range(2, 10):
|
||||
@ -514,7 +514,7 @@ def main(argv):
|
||||
i=i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(100)
|
||||
|
@ -130,7 +130,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -149,7 +149,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -171,11 +171,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -96,7 +96,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -117,7 +117,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -143,11 +143,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -178,7 +178,7 @@ class switch(object):
|
||||
def as9716_32d_set_fan_speed(pwm):
|
||||
|
||||
if pwm < 0 or pwm > 100:
|
||||
print("Error: Wrong duty cycle value %d" % (pwm))
|
||||
print(("Error: Wrong duty cycle value %d" % (pwm)))
|
||||
return -1
|
||||
platform_chassis.get_fan(0).set_speed(pwm)
|
||||
time.sleep(1)
|
||||
@ -477,11 +477,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdlt:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print("Usage: %s [-d] [-l <log_file>]" % sys.argv[0])
|
||||
print(("Usage: %s [-d] [-l <log_file>]" % sys.argv[0]))
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print("Usage: %s [-d] [-l <log_file>]" % sys.argv[0])
|
||||
print(("Usage: %s [-d] [-l <log_file>]" % sys.argv[0]))
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -106,8 +106,8 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
print((sys.argv[0]))
|
||||
print(('ARGV :', sys.argv[1:]))
|
||||
|
||||
|
||||
def main():
|
||||
@ -125,7 +125,7 @@ def main():
|
||||
if DEBUG == True:
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
print((len(sys.argv)))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -149,7 +149,7 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
print(( __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}))
|
||||
sys.exit(0)
|
||||
|
||||
def dis_i2c_ir3570a(addr):
|
||||
@ -171,14 +171,14 @@ def ir3570_check():
|
||||
else:
|
||||
ret = 0
|
||||
except Exception as e:
|
||||
print( "Error on ir3570_check() e:" + str(e))
|
||||
print(( "Error on ir3570_check() e:" + str(e)))
|
||||
return -1
|
||||
return ret
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
print(("[ACCTON DBG]: "+txt))
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
@ -192,7 +192,7 @@ def log_os_system(cmd, show):
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -345,7 +345,7 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
print((PROJECT_NAME.upper()+" drivers detected...."))
|
||||
|
||||
ir3570_check()
|
||||
|
||||
@ -355,12 +355,12 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
print((PROJECT_NAME.upper()+" devices detected...."))
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print(PROJECT_NAME.upper()+" has no device installed....")
|
||||
print((PROJECT_NAME.upper()+" has no device installed...."))
|
||||
else:
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
@ -369,7 +369,7 @@ def do_uninstall():
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print(PROJECT_NAME.upper()+" has no driver installed....")
|
||||
print((PROJECT_NAME.upper()+" has no driver installed...."))
|
||||
else:
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
|
@ -1,81 +1,81 @@
|
||||
#!/usr/bin/env python
|
||||
# Script to stop and start the respective platforms default services.
|
||||
# This will be used while switching the pddf->non-pddf mode and vice versa
|
||||
import commands
|
||||
import subprocess
|
||||
|
||||
def check_pddf_support():
|
||||
return True
|
||||
|
||||
def stop_platform_svc():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as9716-32d-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as9716-32d-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Stop as9716-32d-platform-fan.service failed %d"%status
|
||||
print("Stop as9716-32d-platform-fan.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as9716-32d-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as9716-32d-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Stop as9716-32d-platform-psu.service failed %d"%status
|
||||
print("Stop as9716-32d-platform-psu.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as9716-32d-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop as9716-32d-platform-monitor.service")
|
||||
if status:
|
||||
print "Stop as9716-32d-platform-init.service failed %d"%status
|
||||
print("Stop as9716-32d-platform-init.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as9716-32d-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl disable as9716-32d-platform-monitor.service")
|
||||
if status:
|
||||
print "Disable as9716-32d-platform-monitor.service failed %d"%status
|
||||
print("Disable as9716-32d-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as9716_32d_util.py clean")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as9716_32d_util.py clean")
|
||||
if status:
|
||||
print "accton_as9716_32d_util.py clean command failed %d"%status
|
||||
print("accton_as9716_32d_util.py clean command failed %d"%status)
|
||||
return False
|
||||
|
||||
# HACK , stop the pddf-platform-init service if it is active
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service along with other platform serives failed %d"%status
|
||||
print("Stop pddf-platform-init.service along with other platform serives failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_svc():
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as9716_32d_util.py install")
|
||||
status, output = subprocess.getstatusoutput("/usr/local/bin/accton_as9716_32d_util.py install")
|
||||
if status:
|
||||
print "accton_as9716_32d_util.py install command failed %d"%status
|
||||
print("accton_as9716_32d_util.py install command failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl enable as9716-32d-platform-monitor.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl enable as9716-32d-platform-monitor.service")
|
||||
if status:
|
||||
print "Enable as9716-32d-platform-monitor.service failed %d"%status
|
||||
print("Enable as9716-32d-platform-monitor.service failed %d"%status)
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as9716-32d-platform-monitor-fan.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as9716-32d-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Start as9716-32d-platform-monitor-fan.service failed %d"%status
|
||||
print("Start as9716-32d-platform-monitor-fan.service failed %d"%status)
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl start as9716-32d-platform-monitor-psu.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start as9716-32d-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Start as9716-32d-platform-monitor-psu.service failed %d"%status
|
||||
print("Start as9716-32d-platform-monitor-psu.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_pddf():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
if status:
|
||||
print "Start pddf-platform-init.service failed %d"%status
|
||||
print("Start pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def stop_platform_pddf():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
status, output = subprocess.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service failed %d"%status
|
||||
print("Stop pddf-platform-init.service failed %d"%status)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
@ -182,7 +182,7 @@ class FanUtil(object):
|
||||
try:
|
||||
val_file = open(self.FAN_DUTY_PATH)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
content = val_file.readline().rstrip()
|
||||
@ -194,7 +194,7 @@ class FanUtil(object):
|
||||
try:
|
||||
fan_file = open(self.FAN_DUTY_PATH, 'r+')
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
|
||||
fan_file.write(str(val))
|
||||
|
@ -20,7 +20,7 @@
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -205,7 +205,7 @@ class switch(object):
|
||||
|
||||
def power_off_dut():
|
||||
cmd_str="i2cset -y -f 1 0x60 0x60 0x10"
|
||||
status, output = commands.getstatusoutput(cmd_str)
|
||||
status, output = subprocess.getstatusoutput(cmd_str)
|
||||
return status
|
||||
|
||||
#If only one PSU insert(or one of PSU pwoer fail), and watt >800w. Must let DUT fan pwm >= 75% in AFO.
|
||||
@ -530,11 +530,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlt:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -543,7 +543,7 @@ def main(argv):
|
||||
|
||||
if sys.argv[1]== '-t':
|
||||
if len(sys.argv)!=9:
|
||||
print "temp test, need input 7 temp"
|
||||
print("temp test, need input 7 temp")
|
||||
return 0
|
||||
i=0
|
||||
for x in range(2, 9):
|
||||
@ -551,7 +551,7 @@ def main(argv):
|
||||
i=i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print test_temp_list
|
||||
print(test_temp_list)
|
||||
|
||||
fan = FanUtil()
|
||||
fan.set_fan_duty_cycle(100)
|
||||
|
@ -126,7 +126,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -145,7 +145,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -167,11 +167,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -92,7 +92,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -113,7 +113,7 @@ class device_monitor(object):
|
||||
try:
|
||||
val_file = open(node)
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
print("Error: unable to open file: %s" % str(e))
|
||||
return False
|
||||
content = val_file.readline().rstrip()
|
||||
val_file.close()
|
||||
@ -139,11 +139,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdl:',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
|
@ -29,7 +29,7 @@ command:
|
||||
set : change board setting with fan|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -180,9 +180,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -193,7 +193,7 @@ def main():
|
||||
elif opt in ('-f', '--force'):
|
||||
FORCE = 1
|
||||
else:
|
||||
print "TEST"
|
||||
print("TEST")
|
||||
logging.info('no option')
|
||||
for arg in args:
|
||||
if arg == 'install':
|
||||
@ -227,41 +227,41 @@ def main():
|
||||
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName': sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName': sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1] + " " + args[0]
|
||||
print cmd + " [sfp|fan]"
|
||||
print " use \"" + cmd + " fan 0-100\" to set fan duty percetage"
|
||||
print " use \"" + cmd + " sfp 33-34 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd + " [sfp|fan]")
|
||||
print(" use \"" + cmd + " fan 0-100\" to set fan duty percetage")
|
||||
print(" use \"" + cmd + " sfp 33-34 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1] + " " + args[0]
|
||||
print " use \"" + cmd + " 1-32 \" to dump sfp# eeprom"
|
||||
print(" use \"" + cmd + " 1-32 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG:
|
||||
print "[ACCTON DBG]: " + txt
|
||||
print("[ACCTON DBG]: " + txt)
|
||||
return
|
||||
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :' + cmd)
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log(cmd + "with result:" + str(status))
|
||||
my_log("cmd:" + cmd)
|
||||
my_log(" output:" + output)
|
||||
if status:
|
||||
logging.info('Failed :' + cmd)
|
||||
if show:
|
||||
print('Failed :' + cmd)
|
||||
print(('Failed :' + cmd))
|
||||
return status, output
|
||||
|
||||
|
||||
@ -302,7 +302,7 @@ def driver_uninstall():
|
||||
for i in range(0, len(kos)):
|
||||
rm = kos[-(i + 1)].replace("modprobe", "modprobe -rq")
|
||||
lst = rm.split(" ")
|
||||
print "lst=%s" % lst
|
||||
print("lst=%s" % lst)
|
||||
if len(lst) > 3:
|
||||
del(lst[3])
|
||||
rm = " ".join(lst)
|
||||
@ -323,7 +323,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
print("Check SFP")
|
||||
@ -338,7 +338,7 @@ def device_install():
|
||||
str(sfp_map[i]) +
|
||||
"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -348,7 +348,7 @@ def device_install():
|
||||
str(sfp_map[i]) +
|
||||
"-0050/port_name", 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -363,7 +363,7 @@ def device_uninstall():
|
||||
str(sfp_map[i]) + "/delete_device"
|
||||
status, output = log_os_system("echo 0x50 > " + target, 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -376,7 +376,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -387,7 +387,7 @@ def system_ready():
|
||||
if driver_inserted() == False:
|
||||
return False
|
||||
if not device_exist():
|
||||
print "not device_exist()"
|
||||
print("not device_exist()")
|
||||
return False
|
||||
return True
|
||||
|
||||
@ -403,29 +403,29 @@ def do_sonic_platform_install():
|
||||
if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3):
|
||||
status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1)
|
||||
if status:
|
||||
print "Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
return status
|
||||
else:
|
||||
print "Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3)
|
||||
print("Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
else:
|
||||
print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
else:
|
||||
print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
def do_sonic_platform_clean():
|
||||
status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0)
|
||||
if status:
|
||||
print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
else:
|
||||
status, output = log_os_system("pip3 uninstall sonic-platform -y", 0)
|
||||
if status:
|
||||
print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
return status
|
||||
else:
|
||||
print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3))
|
||||
print(('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)))
|
||||
|
||||
return
|
||||
|
||||
@ -437,14 +437,14 @@ def do_install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + " drivers detected...."
|
||||
print(PROJECT_NAME.upper() + " drivers detected....")
|
||||
if not device_exist():
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper() + " devices detected...."
|
||||
print(PROJECT_NAME.upper() + " devices detected....")
|
||||
|
||||
# for i in range(len(cpld_set)):
|
||||
# status, output = log_os_system(cpld_set[i], 1)
|
||||
@ -459,18 +459,18 @@ def do_install():
|
||||
|
||||
def do_uninstall():
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() + " has no device installed...."
|
||||
print(PROJECT_NAME.upper() + " has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted() == False:
|
||||
print PROJECT_NAME.upper() + " has no driver installed...."
|
||||
print(PROJECT_NAME.upper() + " has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -539,11 +539,11 @@ def devices_info():
|
||||
# show dict all in the order
|
||||
if DEBUG:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i + ": ")
|
||||
print((i + ": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" " + j)
|
||||
print((" " + j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" " + " " + k)
|
||||
print((" " + " " + k))
|
||||
return
|
||||
|
||||
|
||||
@ -569,15 +569,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
print "node=%s" % node
|
||||
print node + ":"
|
||||
print("node=%s" % node)
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat " + node + "| " + hex_cmd + " -C", 1)
|
||||
if ret == 0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
|
||||
@ -602,10 +602,10 @@ def set_device(args):
|
||||
node = node.replace(node.split("/")[-1], 'fan_duty_cycle_percentage')
|
||||
ret, log = log_os_system("cat " + node, 1)
|
||||
if ret == 0:
|
||||
print ("Previous fan duty: " + log.strip() + "%")
|
||||
print(("Previous fan duty: " + log.strip() + "%"))
|
||||
ret, log = log_os_system("echo " + args[1] + " >" + node, 1)
|
||||
if ret == 0:
|
||||
print ("Current fan duty: " + args[1] + "%")
|
||||
print(("Current fan duty: " + args[1] + "%"))
|
||||
return ret
|
||||
elif args[0] == 'sfp':
|
||||
if int(args[1]) > DEVICE_NO[args[0]] or int(args[1]) < DEVICE_NO[args[0]]-1: #33-34
|
||||
@ -649,24 +649,24 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper() + ": ")
|
||||
print((i.upper() + ": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " " + j + ":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" " + j + ":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat " + k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j + '_', '', func, 1)
|
||||
func = re.sub(i.lower() + '_', '', func, 1)
|
||||
if ret == 0:
|
||||
print func + "=" + log + " ",
|
||||
print(func + "=" + log + " ", end=' ')
|
||||
else:
|
||||
print func + "=" + "X" + " ",
|
||||
print
|
||||
print(func + "=" + "X" + " ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
|
||||
|
@ -13,7 +13,6 @@ include /usr/share/dpkg/pkg-info.mk
|
||||
|
||||
export INSTALL_MOD_DIR:=extra
|
||||
|
||||
PYTHON ?= python2
|
||||
PYTHON3 ?= python3
|
||||
|
||||
PACKAGE_PRE_NAME := sonic-platform-accton
|
||||
@ -29,7 +28,7 @@ SERVICE_DIR := service
|
||||
CONF_DIR := conf
|
||||
|
||||
%:
|
||||
dh $@ --with systemd,python2,python3 --buildsystem=pybuild
|
||||
dh $@ --with systemd,python3 --buildsystem=pybuild
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
@ -40,7 +39,7 @@ build:
|
||||
#make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
|
||||
(for mod in $(MODULE_DIRS); do \
|
||||
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
|
||||
$(PYTHON) $${mod}/setup.py build; \
|
||||
$(PYTHON3) $${mod}/setup.py build; \
|
||||
cd $(MOD_SRC_DIR)/$${mod}; \
|
||||
if [ -f sonic_platform_setup.py ]; then \
|
||||
$(PYTHON3) sonic_platform_setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \
|
||||
@ -73,7 +72,7 @@ binary-indep:
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
|
||||
$(PYTHON) $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \
|
||||
$(PYTHON3) $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \
|
||||
done)
|
||||
# Resuming debhelper scripts
|
||||
dh_testroot
|
||||
|
@ -176,9 +176,9 @@ def show_qsfp_present_status(pim_num):
|
||||
interrupt = fpga_io(dom_base[pim_num]+dom["qsfp_present_intr"])
|
||||
mask = fpga_io(dom_base[pim_num]+dom["qsfp_present_intr_mask"])
|
||||
|
||||
print
|
||||
print()
|
||||
print(" (0x48) (0x50) (0x58)")
|
||||
print(" 0x%08X 0x%08X 0x%08X" %(status, interrupt, mask))
|
||||
print((" 0x%08X 0x%08X 0x%08X" %(status, interrupt, mask)))
|
||||
print(" Status Interrupt Mask")
|
||||
for row in range(8):
|
||||
output_str = str()
|
||||
@ -188,11 +188,11 @@ def show_qsfp_present_status(pim_num):
|
||||
interrupt_right = bool(interrupt & (0x2 << row*2))
|
||||
mask_left = bool(mask & (0x1 << row*2))
|
||||
mask_right = bool(mask & (0x2 << row*2))
|
||||
print("%2d: %d %d %d %d %d %d" % \
|
||||
print(("%2d: %d %d %d %d %d %d" % \
|
||||
(row*2+1, status_left, status_right, \
|
||||
interrupt_left, interrupt_right, \
|
||||
mask_left, mask_right))
|
||||
print
|
||||
mask_left, mask_right)))
|
||||
print()
|
||||
|
||||
|
||||
|
||||
@ -319,13 +319,13 @@ class PimUtil(object):
|
||||
elif timeout > 0:
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
else:
|
||||
print "get_transceiver_change_event:Invalid timeout value", timeout
|
||||
print("get_transceiver_change_event:Invalid timeout value", timeout)
|
||||
return False, {}
|
||||
|
||||
end_time = start_time + timeout
|
||||
if start_time > end_time:
|
||||
print 'get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout
|
||||
print('get_transceiver_change_event:' \
|
||||
'time wrap / invalid timeout value', timeout)
|
||||
|
||||
return False, {} # Time wrap or possibly incorrect timeout
|
||||
|
||||
@ -361,7 +361,7 @@ class PimUtil(object):
|
||||
if timeout > 0:
|
||||
time.sleep(timeout)
|
||||
return True, {}
|
||||
print "get_evt_change_event: Should not reach here."
|
||||
print("get_evt_change_event: Should not reach here.")
|
||||
return False, {}
|
||||
|
||||
|
||||
@ -382,7 +382,7 @@ class PimUtil(object):
|
||||
elif color==0:
|
||||
led_val = (led_val & ( ~ 0x8000)) | 0x4000 #amber
|
||||
else:
|
||||
print "Set RGB control to Green1"
|
||||
print("Set RGB control to Green1")
|
||||
led_val = led_val & (~ 0x4000)
|
||||
led_val = led_val & (~ 0xfff)
|
||||
led_val = led_val | 0x0f0 #B.G.R Birghtness, set to Green
|
||||
@ -547,30 +547,30 @@ class PimUtil(object):
|
||||
elif color==0x1C:
|
||||
color=4 #green
|
||||
|
||||
print "color=%d, control=%d"%(color, control)
|
||||
print("color=%d, control=%d"%(color, control))
|
||||
return color, control
|
||||
|
||||
def main(argv):
|
||||
init_resources()
|
||||
pim=PimUtil()
|
||||
print "Test Board ID"
|
||||
print("Test Board ID")
|
||||
for x in range(0,8):
|
||||
val=pim.get_pim_board_id(x)
|
||||
print "pim=%d"%x
|
||||
print("pim=%d"%x)
|
||||
if val==0:
|
||||
print "100G board"
|
||||
print("100G board")
|
||||
else:
|
||||
print "400G board"
|
||||
print("400G board")
|
||||
|
||||
print "Test pim presence"
|
||||
print("Test pim presence")
|
||||
for x in range(0,8):
|
||||
pres=pim.get_pim_presence(x)
|
||||
print "pim=%d, presence=%d"%(x, pres)
|
||||
print("pim=%d, presence=%d"%(x, pres))
|
||||
|
||||
print "Test pim status"
|
||||
print("Test pim status")
|
||||
for x in range(0,8):
|
||||
power_status=pim.get_pim_status(x)
|
||||
print "pim=%d power_status=0x%x"%(x, power_status)
|
||||
print("pim=%d power_status=0x%x"%(x, power_status))
|
||||
|
||||
release_resources()
|
||||
|
||||
|
@ -37,7 +37,7 @@ command:
|
||||
set : change board setting with led|sfp
|
||||
"""
|
||||
|
||||
import commands
|
||||
import subprocess
|
||||
import getopt
|
||||
import sys
|
||||
import logging
|
||||
@ -86,8 +86,8 @@ FORCE = 0
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
print(sys.argv[0])
|
||||
print('ARGV :', sys.argv[1:])
|
||||
|
||||
|
||||
def main():
|
||||
@ -103,9 +103,9 @@ def main():
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
print(options)
|
||||
print(args)
|
||||
print(len(sys.argv))
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
@ -146,38 +146,38 @@ def main():
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
print(__doc__ % {'scriptName' : sys.argv[0].split("/")[-1]})
|
||||
sys.exit(0)
|
||||
|
||||
def show_set_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print cmd +" [led|sfp]"
|
||||
print " use \""+ cmd + " led 0-4 \" to set led color"
|
||||
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
|
||||
print(cmd +" [led|sfp]")
|
||||
print(" use \""+ cmd + " led 0-4 \" to set led color")
|
||||
print(" use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable")
|
||||
sys.exit(0)
|
||||
|
||||
def show_eeprom_help():
|
||||
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
|
||||
print " use \""+ cmd + " 1-54 \" to dump sfp# eeprom"
|
||||
print(" use \""+ cmd + " 1-54 \" to dump sfp# eeprom")
|
||||
sys.exit(0)
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
my_log (cmd +"with result:" + str(status))
|
||||
my_log ("cmd:" + cmd)
|
||||
my_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
print(('Failed :'+cmd))
|
||||
return status, output
|
||||
|
||||
def driver_inserted():
|
||||
@ -243,7 +243,7 @@ def device_install():
|
||||
|
||||
status, output = log_os_system(mknod[i], 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -263,7 +263,7 @@ def device_uninstall():
|
||||
temp[-1] = temp[-1].replace('new_device', 'delete_device')
|
||||
status, output = log_os_system(" ".join(temp), 1)
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
@ -277,40 +277,40 @@ def system_ready():
|
||||
return True
|
||||
|
||||
def do_install():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if driver_inserted() == False:
|
||||
print "No driver, installing...."
|
||||
print("No driver, installing....")
|
||||
status = driver_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" drivers detected...."
|
||||
print(PROJECT_NAME.upper()+" drivers detected....")
|
||||
if not device_exist():
|
||||
print "No device, installing...."
|
||||
print("No device, installing....")
|
||||
status = device_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print PROJECT_NAME.upper()+" devices detected...."
|
||||
print(PROJECT_NAME.upper()+" devices detected....")
|
||||
return
|
||||
|
||||
def do_uninstall():
|
||||
print "Checking system...."
|
||||
print("Checking system....")
|
||||
if not device_exist():
|
||||
print PROJECT_NAME.upper() +" has no device installed...."
|
||||
print(PROJECT_NAME.upper() +" has no device installed....")
|
||||
else:
|
||||
print "Removing device...."
|
||||
print("Removing device....")
|
||||
status = device_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
if driver_inserted()== False :
|
||||
print PROJECT_NAME.upper() +" has no driver installed...."
|
||||
print(PROJECT_NAME.upper() +" has no driver installed....")
|
||||
else:
|
||||
print "Removing installed driver...."
|
||||
print("Removing installed driver....")
|
||||
status = driver_uninstall()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
@ -358,11 +358,11 @@ def devices_info():
|
||||
#show dict all in the order
|
||||
if DEBUG == True:
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print(i+": ")
|
||||
print((i+": "))
|
||||
for j in sorted(ALL_DEVICE[i].keys()):
|
||||
print(" "+j)
|
||||
print((" "+j))
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
print(" "+" "+k)
|
||||
print((" "+" "+k))
|
||||
return
|
||||
|
||||
def show_eeprom(index):
|
||||
@ -385,15 +385,15 @@ def show_eeprom(index):
|
||||
else:
|
||||
log = 'Failed : no hexdump cmd!!'
|
||||
logging.info(log)
|
||||
print log
|
||||
print(log)
|
||||
return 1
|
||||
|
||||
print node + ":"
|
||||
print(node + ":")
|
||||
ret, log = log_os_system("cat "+node+"| "+hex_cmd+" -C", 1)
|
||||
if ret==0:
|
||||
print log
|
||||
print(log)
|
||||
else:
|
||||
print "**********device no found**********"
|
||||
print("**********device no found**********")
|
||||
return
|
||||
|
||||
def set_device(args):
|
||||
@ -455,25 +455,25 @@ def device_traversal():
|
||||
devices_info()
|
||||
for i in sorted(ALL_DEVICE.keys()):
|
||||
print("============================================")
|
||||
print(i.upper()+": ")
|
||||
print((i.upper()+": "))
|
||||
print("============================================")
|
||||
|
||||
for j in sorted(ALL_DEVICE[i].keys(), key=get_value):
|
||||
print " "+j+":",
|
||||
for j in sorted(list(ALL_DEVICE[i].keys()), key=get_value):
|
||||
print(" "+j+":", end=' ')
|
||||
for k in (ALL_DEVICE[i][j]):
|
||||
ret, log = log_os_system("cat "+k, 0)
|
||||
func = k.split("/")[-1].strip()
|
||||
func = re.sub(j+'_','',func,1)
|
||||
func = re.sub(i.lower()+'_','',func,1)
|
||||
if ret==0:
|
||||
print func+"="+log+" ",
|
||||
print(func+"="+log+" ", end=' ')
|
||||
else:
|
||||
print func+"="+"X"+" ",
|
||||
print
|
||||
print(func+"="+"X"+" ", end=' ')
|
||||
print()
|
||||
print("----------------------------------------------------------------")
|
||||
|
||||
|
||||
print
|
||||
print()
|
||||
return
|
||||
|
||||
def device_exist():
|
||||
|
@ -21,13 +21,9 @@
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import os
|
||||
import getopt
|
||||
import sys
|
||||
import subprocess
|
||||
import click
|
||||
import imp
|
||||
import commands
|
||||
import logging
|
||||
import logging.config
|
||||
import logging.handlers
|
||||
@ -72,14 +68,14 @@ PIM_MAX=8
|
||||
|
||||
def my_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[ACCTON DBG]: "+txt
|
||||
print("[ACCTON DBG]: "+txt)
|
||||
return
|
||||
|
||||
def log_os_system(cmd):
|
||||
logging.info('Run :'+cmd)
|
||||
status = 1
|
||||
output = ""
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
return status, output
|
||||
@ -123,7 +119,7 @@ def qsfp_eeprom_sys(pim_idx, i2c_bus_order, create):
|
||||
status, output =log_os_system(
|
||||
"echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(bus)+"/new_device")
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
return 1
|
||||
status, output =log_os_system(
|
||||
"echo port"+str(k+1)+" > /sys/bus/i2c/devices/"+str(bus)+"-0050/port_name")
|
||||
@ -131,13 +127,13 @@ def qsfp_eeprom_sys(pim_idx, i2c_bus_order, create):
|
||||
status, output =log_os_system(
|
||||
"ln -s -f /sys/bus/i2c/devices/"+str(bus)+"-0050/eeprom" + " /usr/local/bin/minipack_qsfp/port" + str(k) + "_eeprom")
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
return 1
|
||||
else:
|
||||
status, output =log_os_system(
|
||||
"echo 0x50 > /sys/bus/i2c/devices/i2c-"+str(bus)+"/delete_device")
|
||||
if status:
|
||||
print output
|
||||
print(output)
|
||||
|
||||
k=k+1
|
||||
|
||||
@ -146,7 +142,7 @@ def qsfp_eeprom_sys(pim_idx, i2c_bus_order, create):
|
||||
def check_pca_active( i2c_addr, bus):
|
||||
cmd = "i2cget -y -f %d 0x%x 0x0"
|
||||
cmd = cmd %(bus, i2c_addr)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
status, output = subprocess.getstatusoutput(cmd)
|
||||
return status
|
||||
|
||||
def set_pim_port_use_bus(pim_idx):
|
||||
@ -178,11 +174,11 @@ def device_remove():
|
||||
#if ret==0:
|
||||
|
||||
cmdm= cmd1 % (0x72, bus)
|
||||
status, output = commands.getstatusoutput(cmdm)
|
||||
print "Remove %d-0072 i2c device"%bus
|
||||
status, output = subprocess.getstatusoutput(cmdm)
|
||||
print("Remove %d-0072 i2c device"%bus)
|
||||
cmdm= cmd1 % (0x71, bus)
|
||||
status, output = commands.getstatusoutput(cmdm)
|
||||
print "Remove %d-0071 i2c device"%bus
|
||||
status, output = subprocess.getstatusoutput(cmdm)
|
||||
print("Remove %d-0071 i2c device"%bus)
|
||||
|
||||
cmd="rm -f /usr/local/bin/minipack_qsfp/port*"
|
||||
status, output=log_os_system(cmd)
|
||||
@ -262,7 +258,7 @@ class device_monitor(object):
|
||||
pim_state[pim_idx]=self.PIM_STATE_INSERT
|
||||
logging.info("pim_state[%d] PIM_STATE_INSERT", pim_idx);
|
||||
else:
|
||||
print "retry check 100 times for check pca addr"
|
||||
print("retry check 100 times for check pca addr")
|
||||
del_pim_port_use_bus(pim_idx)
|
||||
else:
|
||||
if pim_state[pim_idx]==self.PIM_STATE_INSERT:
|
||||
@ -280,11 +276,11 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,'hdlr',['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print 'A:Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('A:Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'B:Usage: %s [-d] [-l <log_file>]' % sys.argv[0]
|
||||
print('B:Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
@ -305,7 +301,7 @@ def main(argv):
|
||||
time.sleep(0.5)
|
||||
if status==0:
|
||||
cpu_pca_i2c_ready=1
|
||||
print "Make sure CPU pca i2c device is ready"
|
||||
print("Make sure CPU pca i2c device is ready")
|
||||
break
|
||||
|
||||
while True:
|
||||
|
Reference in New Issue
Block a user