Skip to content

Commit 8d48e6f

Browse files
jlevequesanthosh-kt
authored andcommitted
[sonic-utilities] Update submodule; Build and install as a Python 3 wheel (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) (sonic-net#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
1 parent b88f42a commit 8d48e6f

File tree

341 files changed

+6642
-6732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+6642
-6732
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#!/usr/bin/env python
2-
31
try:
4-
import exceptions
52
import binascii
63
import time
74
import optparse
@@ -11,11 +8,13 @@
118
from sonic_eeprom import eeprom_base
129
from sonic_eeprom import eeprom_tlvinfo
1310
import subprocess
14-
except ImportError, e:
15-
raise ImportError (str(e) + "- required module not found")
11+
except ImportError as e:
12+
raise ImportError(str(e) + "- required module not found")
13+
1614

1715
class board(eeprom_tlvinfo.TlvInfoDecoder):
1816
_TLV_INFO_MAX_LEN = 256
17+
1918
def __init__(self, name, path, cpld_root, ro):
2019
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
2120
super(board, self).__init__(self.eeprom_path, 0, '', True)

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
31
#############################################################################
42
# Accton
53
#
@@ -13,7 +11,8 @@
1311
try:
1412
from sonic_psu.psu_base import PsuBase
1513
except ImportError as e:
16-
raise ImportError (str(e) + "- required module not found")
14+
raise ImportError(str(e) + "- required module not found")
15+
1716

1817
class PsuUtil(PsuBase):
1918
"""Platform-specific PSUutil class"""

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

+22-21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SFP_STATUS_INSERTED = '1'
1616
SFP_STATUS_REMOVED = '0'
1717

18+
1819
class SfpUtil(SfpUtilBase):
1920
"""Platform-specific SfpUtil class"""
2021

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

3233
_port_to_eeprom_mapping = {}
3334
_port_to_i2c_mapping = {
34-
49: [18],
35-
50: [19],
36-
51: [20],
37-
52: [21],
38-
53: [22],
39-
54: [23],
40-
}
35+
49: [18],
36+
50: [19],
37+
51: [20],
38+
52: [21],
39+
53: [22],
40+
54: [23],
41+
}
4142

4243
@property
4344
def port_start(self):
@@ -49,7 +50,7 @@ def port_end(self):
4950

5051
@property
5152
def qsfp_ports(self):
52-
return range(self.PORT_START, self.PORTS_IN_BLOCK + 1)
53+
return list(range(self.PORT_START, self.PORTS_IN_BLOCK + 1))
5354

5455
@property
5556
def port_to_eeprom_mapping(self):
@@ -70,15 +71,15 @@ def get_presence(self, port_num):
7071
present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num)
7172
self.__port_to_is_present = present_path
7273

73-
content="0"
74+
content = "0"
7475
try:
7576
val_file = open(self.__port_to_is_present)
7677
content = val_file.readline().rstrip()
7778
val_file.close()
7879
except IOError as e:
79-
print "Error: unable to access file: %s" % str(e)
80+
print("Error: unable to access file: %s" % str(e))
8081
return False
81-
82+
8283
if content == "1":
8384
return True
8485

@@ -108,7 +109,7 @@ def get_low_power_mode(self, port_num):
108109
return False
109110

110111
except IOError as e:
111-
print "Error: unable to open file: %s" % str(e)
112+
print("Error: unable to open file: %s" % str(e))
112113
return False
113114
finally:
114115
if eeprom is not None:
@@ -123,7 +124,7 @@ def set_low_power_mode(self, port_num, lpmode):
123124
try:
124125
eeprom = None
125126
if not self.get_presence(port_num):
126-
return False # Port is not present, unable to set the eeprom
127+
return False # Port is not present, unable to set the eeprom
127128

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

154155
bits = []
155156
for x in range(self.port_start, self.port_end+1):
156-
bits.append(str(int(self.get_presence(x))))
157+
bits.append(str(int(self.get_presence(x))))
157158

158159
rev = "".join(bits[::-1])
159-
return int(rev,2)
160+
return int(rev, 2)
161+
162+
data = {'present': 0}
160163

161-
data = {'present':0}
162164
def get_transceiver_change_event(self, timeout=0):
163165
port_dict = {}
164166

165167
if timeout == 0:
166-
cd_ms = sys.maxint
168+
cd_ms = sys.maxsize
167169
else:
168170
cd_ms = timeout
169171

170-
#poll per second
172+
# poll per second
171173
while cd_ms > 0:
172174
reg_value = self._get_presence_bitmap
173175
changed_ports = self.data['present'] ^ reg_value
@@ -177,7 +179,7 @@ def get_transceiver_change_event(self, timeout=0):
177179
cd_ms = cd_ms - 1000
178180

179181
if changed_ports != 0:
180-
for port in range (self.port_start, self.port_end+1):
182+
for port in range(self.port_start, self.port_end+1):
181183
# Mask off the bit corresponding to our port
182184
mask = (1 << (port - self.port_start))
183185
if changed_ports & mask:
@@ -192,4 +194,3 @@ def get_transceiver_change_event(self, timeout=0):
192194
else:
193195
return True, {}
194196
return False, {}
195-
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#!/usr/bin/env python
2-
31
try:
4-
import exceptions
52
import binascii
63
import time
74
import optparse
@@ -11,14 +8,16 @@
118
from sonic_eeprom import eeprom_base
129
from sonic_eeprom import eeprom_tlvinfo
1310
import subprocess
14-
except ImportError, e:
15-
raise ImportError (str(e) + "- required module not found")
11+
except ImportError as e:
12+
raise ImportError(str(e) + "- required module not found")
13+
1614

1715
class board(eeprom_tlvinfo.TlvInfoDecoder):
1816
_TLV_INFO_MAX_LEN = 256
17+
1918
def __init__(self, name, path, cpld_root, ro):
2019
self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom"
21-
#Two i2c buses might get flipped order, check them both.
20+
# Two i2c buses might get flipped order, check them both.
2221
if not os.path.exists(self.eeprom_path):
2322
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
2423
super(board, self).__init__(self.eeprom_path, 0, '', True)

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#!/usr/bin/env python
2-
31
#############################################################################
42
# Accton
53
#
@@ -13,7 +11,8 @@
1311
try:
1412
from sonic_psu.psu_base import PsuBase
1513
except ImportError as e:
16-
raise ImportError (str(e) + "- required module not found")
14+
raise ImportError(str(e) + "- required module not found")
15+
1716

1817
class PsuUtil(PsuBase):
1918
"""Platform-specific PSUutil class"""

0 commit comments

Comments
 (0)