Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[thci] convert Python2 script to Python3 #310

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/commissioner_thci/commissioner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2019, The OpenThread Commissioner Authors.
Expand Down
4 changes: 1 addition & 3 deletions tools/commissioner_thci/commissioner_ctl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2019, The OpenThread Commissioner Authors.
Expand Down Expand Up @@ -30,8 +30,6 @@
Commissioner daemon controller
"""

from __future__ import print_function

import os
import argparse
import multiprocessing.connection
Expand Down
10 changes: 5 additions & 5 deletions tools/commissioner_thci/commissioner_impl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2019, The OpenThread Commissioner Authors.
Expand Down Expand Up @@ -194,7 +194,7 @@ def getSessionId(self):
raise_(commissioner.Error, repr(e), sys.exc_info()[2])

def MGMT_COMMISSIONER_GET(self, tlvTypes):
types = ' '.join(map(lambda x: TLV_TYPE_TO_STRING[x], tlvTypes))
types = ' '.join([TLV_TYPE_TO_STRING[x] for x in tlvTypes])
command = 'commdataset get ' + types
response = self._execute_and_check(command)

Expand Down Expand Up @@ -252,7 +252,7 @@ def disableJoiner(self, joinerType, eui64=None):
self._execute_and_check(' '.join(command))

def MGMT_ACTIVE_GET(self, tlvTypes):
types = ' '.join(map(lambda x: TLV_TYPE_TO_STRING[x], tlvTypes))
types = ' '.join([TLV_TYPE_TO_STRING[x] for x in tlvTypes])
result = self._execute_and_check(
'opdataset get active {}'.format(types))

Expand All @@ -267,7 +267,7 @@ def MGMT_ACTIVE_SET(self, activeOpDataset):
OTCommissioner._active_op_dataset_to_json(activeOpDataset)))

def MGMT_PENDING_GET(self, tlvTypes):
types = ' '.join(map(lambda x: TLV_TYPE_TO_STRING[x], tlvTypes))
types = ' '.join([TLV_TYPE_TO_STRING[x] for x in tlvTypes])
result = self._execute_and_check(
'opdataset get pending {}'.format(types))

Expand All @@ -282,7 +282,7 @@ def MGMT_PENDING_SET(self, pendingOpDataset):
OTCommissioner._pending_op_dataset_to_json(pendingOpDataset)))

def MGMT_BBR_GET(self, tlvTypes):
types = ' '.join(map(lambda x: TLV_TYPE_TO_STRING[x], tlvTypes))
types = ' '.join([TLV_TYPE_TO_STRING[x] for x in tlvTypes])
result = self._execute_and_check('bbrdataset get {}'.format(types))

try:
Expand Down
4 changes: 1 addition & 3 deletions tools/commissioner_thci/commissionerd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2019, The OpenThread Commissioner Authors.
Expand Down Expand Up @@ -30,8 +30,6 @@
Commissioner daemon process
"""

from __future__ import print_function

import os
import multiprocessing.connection
import sys
Expand Down
6 changes: 3 additions & 3 deletions tools/commissioner_thci/example_send_mlr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2019, The OpenThread Commissioner Authors.
Expand Down Expand Up @@ -71,8 +71,8 @@ def test_mlr():
comm.start(BORDER_AGENT_ADDR, BORDER_AGENT_PORT)
assert comm.isActive()

print("commissioner connected, session ID = {}".format(
comm.getSessionId()))
print(("commissioner connected, session ID = {}".format(
comm.getSessionId())))
yangsong-cnyn marked this conversation as resolved.
Show resolved Hide resolved

## Send MLR.req
comm.MLR([MA1, MA2], 60)
Expand Down
Loading