Skip to content

Commit

Permalink
[sonic-utilities] Update submodule; Build and install as a Python 3 w…
Browse files Browse the repository at this point in the history
…heel (sonic-net#5926)

Submodule updates include the following commits:

* src/sonic-utilities 9dc58ea...f9eb739 (18):
  > Remove unnecessary calls to str.encode() now that the package is Python 3; Fix deprecation warning (sonic-net#1260)
  > [generate_dump] Ignoring file/directory not found Errors (sonic-net#1201)
  > Fixed porstat rate and util issues (sonic-net#1140)
  > fix error: interface counters is mismatch after warm-reboot (sonic-net#1099)
  > Remove unnecessary calls to str.decode() now that the package is Python 3 (sonic-net#1255)
  > [acl-loader] Make list sorting compliant with Python 3 (sonic-net#1257)
  > Replace hard-coded fast-reboot with variable. And some typo corrections (sonic-net#1254)
  > [configlet][portconfig] Remove calls to dict.has_key() which is not available in Python 3 (sonic-net#1247)
  > Remove unnecessary conversions to list() and calls to dict.keys() (sonic-net#1243)
  > Clean up LGTM alerts (sonic-net#1239)
  > Add 'requests' as install dependency in setup.py (sonic-net#1240)
  > Convert to Python 3 (sonic-net#1128)
  > Fix mock SonicV2Connector in python3: use decode_responses mode so caller code will be the same as python2 (sonic-net#1238)
  > [tests] Do not trim from PATH if we did not append to it; Clean up/fix shebangs in scripts (sonic-net#1233)
  > Updates to bgp config and show commands with BGP_INTERNAL_NEIGHBOR table (sonic-net#1224)
  > [cli]: NAT show commands newline issue after migrated to Python3 (sonic-net#1204)
  > [doc]: Update Command-Reference.md (sonic-net#1231)
  > Added 'import sys' in feature.py file (sonic-net#1232)

* src/sonic-py-swsssdk 9d9f0c6...1664be9 (2):
  > Fix: no need to decode() after redis client scan, so it will work for both python2 and python3 (sonic-net#96)
  > FieldValueMap `contains`(`in`)  will also work when migrated to libswsscommon(C++ with SWIG wrapper) (#94)

- Also fix Python 3-related issues:
    - Use integer (floor) division in config_samples.py (sonic-config-engine)
    - Replace print statement with print function in eeprom.py plugin for x86_64-kvm_x86_64-r0 platform
    - Update all platform plugins to be compatible with both Python 2 and Python 3
    - Remove shebangs from plugins files which are not intended to be executable
    - Replace tabs with spaces in Python plugin files and fix alignment, because Python 3 is more strict
    - Remove trailing whitespace from plugins files
  • Loading branch information
jleveque authored Nov 25, 2020
1 parent fad481e commit 7f4ab8f
Show file tree
Hide file tree
Showing 341 changed files with 6,642 additions and 6,732 deletions.
9 changes: 4 additions & 5 deletions device/accton/x86_64-accton_as4630_54pe-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python

try:
import exceptions
import binascii
import time
import optparse
Expand All @@ -11,11 +8,13 @@
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)
5 changes: 2 additions & 3 deletions device/accton/x86_64-accton_as4630_54pe-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

#############################################################################
# Accton
#
Expand All @@ -13,7 +11,8 @@
try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")
raise ImportError(str(e) + "- required module not found")


class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""
Expand Down
43 changes: 22 additions & 21 deletions device/accton/x86_64-accton_as4630_54pe-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
SFP_STATUS_INSERTED = '1'
SFP_STATUS_REMOVED = '0'


class SfpUtil(SfpUtilBase):
"""Platform-specific SfpUtil class"""

Expand All @@ -31,13 +32,13 @@ class SfpUtil(SfpUtilBase):

_port_to_eeprom_mapping = {}
_port_to_i2c_mapping = {
49: [18],
50: [19],
51: [20],
52: [21],
53: [22],
54: [23],
}
49: [18],
50: [19],
51: [20],
52: [21],
53: [22],
54: [23],
}

@property
def port_start(self):
Expand All @@ -49,7 +50,7 @@ def port_end(self):

@property
def qsfp_ports(self):
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))

@property
def port_to_eeprom_mapping(self):
Expand All @@ -70,15 +71,15 @@ def get_presence(self, port_num):
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
self.__port_to_is_present = present_path

content="0"
content = "0"
try:
val_file = open(self.__port_to_is_present)
content = val_file.readline().rstrip()
val_file.close()
except IOError as e:
print "Error: unable to access file: %s" % str(e)
print("Error: unable to access file: %s" % str(e))
return False

if content == "1":
return True

Expand Down Expand Up @@ -108,7 +109,7 @@ def get_low_power_mode(self, port_num):
return False

except IOError as e:
print "Error: unable to open file: %s" % str(e)
print("Error: unable to open file: %s" % str(e))
return False
finally:
if eeprom is not None:
Expand All @@ -123,7 +124,7 @@ def set_low_power_mode(self, port_num, lpmode):
try:
eeprom = None
if not self.get_presence(port_num):
return False # Port is not present, unable to set the eeprom
return False # Port is not present, unable to set the eeprom

# Fill in write buffer
# 0x3:Low Power Mode, 0x1:High Power Mode
Expand All @@ -138,7 +139,7 @@ def set_low_power_mode(self, port_num, lpmode):
eeprom.write(buffer[0])
return True
except IOError as e:
print "Error: unable to open file: %s" % str(e)
print("Error: unable to open file: %s" % str(e))
return False
finally:
if eeprom is not None:
Expand All @@ -153,21 +154,22 @@ def _get_presence_bitmap(self):

bits = []
for x in range(self.port_start, self.port_end+1):
bits.append(str(int(self.get_presence(x))))
bits.append(str(int(self.get_presence(x))))

rev = "".join(bits[::-1])
return int(rev,2)
return int(rev, 2)

data = {'present': 0}

data = {'present':0}
def get_transceiver_change_event(self, timeout=0):
port_dict = {}

if timeout == 0:
cd_ms = sys.maxint
cd_ms = sys.maxsize
else:
cd_ms = timeout

#poll per second
# poll per second
while cd_ms > 0:
reg_value = self._get_presence_bitmap
changed_ports = self.data['present'] ^ reg_value
Expand All @@ -177,7 +179,7 @@ def get_transceiver_change_event(self, timeout=0):
cd_ms = cd_ms - 1000

if changed_ports != 0:
for port in range (self.port_start, self.port_end+1):
for port in range(self.port_start, self.port_end+1):
# Mask off the bit corresponding to our port
mask = (1 << (port - self.port_start))
if changed_ports & mask:
Expand All @@ -192,4 +194,3 @@ def get_transceiver_change_event(self, timeout=0):
else:
return True, {}
return False, {}

11 changes: 5 additions & 6 deletions device/accton/x86_64-accton_as5712_54x-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env python

try:
import exceptions
import binascii
import time
import optparse
Expand All @@ -11,14 +8,16 @@
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256

def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
#Two i2c buses might get flipped order, check them both.
# Two i2c buses might get flipped order, check them both.
if not os.path.exists(self.eeprom_path):
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
super(board, self).__init__(self.eeprom_path, 0, '', True)
5 changes: 2 additions & 3 deletions device/accton/x86_64-accton_as5712_54x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

#############################################################################
# Accton
#
Expand All @@ -13,7 +11,8 @@
try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
raise ImportError (str(e) + "- required module not found")
raise ImportError(str(e) + "- required module not found")


class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""
Expand Down
Loading

0 comments on commit 7f4ab8f

Please sign in to comment.