Skip to content

Commit

Permalink
[thci] Convert python2 script to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsong-cnyn committed Jan 2, 2025
1 parent 5cff6d6 commit 6307528
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
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())))

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

0 comments on commit 6307528

Please sign in to comment.