Skip to content

Commit 57f9a1e

Browse files
authored
Merge pull request #11921 from madchutney/tools/py3-fixes
Updates to tools for Python 3 compatibility
2 parents 9974d83 + 23b12f4 commit 57f9a1e

Some content is hidden

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

44 files changed

+144
-123
lines changed

tools/device_management.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ def inner(options):
115115
# Get the currently in-use API key (may come from environment or
116116
# configuration files, which is handled by the cloud SDK)
117117
api_key_value = accounts.config.get("api_key")
118-
api_key = accounts.list_api_keys(
118+
api_key = next(accounts.list_api_keys(
119119
filter={
120120
"key": api_key_value
121121
}
122-
).next()
122+
))
123123
certificates_owned = list(certs.list_certificates())
124124
dev_cert_info = None
125125
for certif in certificates_owned:

tools/export/exporters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from tools.targets import TARGET_MAP
2929
from tools.utils import mkdir
3030
from tools.resources import FileType, FileRef
31+
from future.utils import with_metaclass
3132

3233
"""Just a template for subclassing"""
3334

@@ -57,14 +58,13 @@ def __init__(*args, **kwargs):
5758
CLS.NAME = "%s (DEPRECATED)" % old_name
5859
return CLS
5960

60-
class Exporter(object):
61+
class Exporter(with_metaclass(ABCMeta, object)):
6162
"""Exporter base class
6263
6364
This class is meant to be extended by individual exporters, and provides a
6465
few helper methods for implementing an exporter with either jinja2 or
6566
progen.
6667
"""
67-
__metaclass__ = ABCMeta
6868
TEMPLATE_DIR = dirname(__file__)
6969
DOT_IN_RELATIVE_PATH = False
7070
NAME = None

tools/flash_algo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def format_algo_data(self, spaces, group_size, fmt):
134134
blob = self.algo_data[:]
135135
pad_size = 0 if len(blob) % 4 == 0 else 4 - len(blob) % 4
136136
blob = blob + "\x00" * pad_size
137-
integer_list = struct.unpack("<" + "L" * (len(blob) / 4), blob)
137+
integer_list = struct.unpack("<" + "L" * (len(blob) // 4), blob)
138138
line_list = []
139139
for pos in range(0, len(integer_list), group_size):
140140
group = ["0x%08x" % value for value in

tools/host_tests/default_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from sys import stdout
2020

21-
class DefaultAuto():
21+
class DefaultAuto(object):
2222
""" Simple, basic host test's test runner waiting for serial port
2323
output from MUT, no supervision over test running in MUT is executed.
2424
"""

tools/host_tests/detect_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import re
1919

20-
class DetectPlatformTest():
20+
class DetectPlatformTest(object):
2121
PATTERN_MICRO_NAME = "Target '(\w+)'"
2222
re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
2323

tools/host_tests/dev_null_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
limitations under the License.
1616
"""
1717

18-
class DevNullTest():
18+
class DevNullTest(object):
1919

2020
def check_readline(self, selftest, text):
2121
""" Reads line from serial port and checks if text was part of read string

tools/host_tests/echo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import uuid
2020
from sys import stdout
2121

22-
class EchoTest():
22+
class EchoTest(object):
2323

2424
# Test parameters
2525
TEST_SERIAL_BAUDRATE = 115200

tools/host_tests/echo_flow_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from host_test import Test
17+
from .host_test import Test
1818

1919

2020
class EchoTest(Test):

tools/host_tests/hello_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
limitations under the License.
1616
"""
1717

18-
class HelloTest():
18+
class HelloTest(object):
1919
HELLO_WORLD = "Hello World"
2020

2121
def test(self, selftest):

tools/host_tests/host_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
limitations under the License.
1616
"""
1717

18-
class HostRegistry:
18+
class HostRegistry(object):
1919
""" Class stores registry with host tests and objects representing them
2020
"""
2121
HOST_TESTS = {} # host_test_name -> host_test_ojbect

0 commit comments

Comments
 (0)