mirror of https://github.com/ARMmbed/mbed-os.git
Updates to *.py in 'tools/' for Python 3
parent
e723571474
commit
d2b968142d
|
@ -115,11 +115,11 @@ def wrap_init(func):
|
||||||
# Get the currently in-use API key (may come from environment or
|
# Get the currently in-use API key (may come from environment or
|
||||||
# configuration files, which is handled by the cloud SDK)
|
# configuration files, which is handled by the cloud SDK)
|
||||||
api_key_value = accounts.config.get("api_key")
|
api_key_value = accounts.config.get("api_key")
|
||||||
api_key = accounts.list_api_keys(
|
api_key = next(accounts.list_api_keys(
|
||||||
filter={
|
filter={
|
||||||
"key": api_key_value
|
"key": api_key_value
|
||||||
}
|
}
|
||||||
).next()
|
))
|
||||||
certificates_owned = list(certs.list_certificates())
|
certificates_owned = list(certs.list_certificates())
|
||||||
dev_cert_info = None
|
dev_cert_info = None
|
||||||
for certif in certificates_owned:
|
for certif in certificates_owned:
|
||||||
|
|
|
@ -33,6 +33,7 @@ from collections import defaultdict
|
||||||
from prettytable import PrettyTable, HEADER
|
from prettytable import PrettyTable, HEADER
|
||||||
from jinja2 import FileSystemLoader, StrictUndefined
|
from jinja2 import FileSystemLoader, StrictUndefined
|
||||||
from jinja2.environment import Environment
|
from jinja2.environment import Environment
|
||||||
|
from future.utils import with_metaclass
|
||||||
|
|
||||||
|
|
||||||
# Be sure that the tools directory is in the search path
|
# Be sure that the tools directory is in the search path
|
||||||
|
@ -46,9 +47,8 @@ from tools.utils import (
|
||||||
) # noqa: E402
|
) # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
class _Parser(object):
|
class _Parser(with_metaclass(ABCMeta, object)):
|
||||||
"""Internal interface for parsing"""
|
"""Internal interface for parsing"""
|
||||||
__metaclass__ = ABCMeta
|
|
||||||
SECTIONS = ('.text', '.data', '.bss', '.heap', '.stack')
|
SECTIONS = ('.text', '.data', '.bss', '.heap', '.stack')
|
||||||
MISC_FLASH_SECTIONS = ('.interrupts', '.flash_config')
|
MISC_FLASH_SECTIONS = ('.interrupts', '.flash_config')
|
||||||
OTHER_SECTIONS = ('.interrupts_ram', '.init', '.ARM.extab',
|
OTHER_SECTIONS = ('.interrupts_ram', '.init', '.ARM.extab',
|
||||||
|
@ -76,7 +76,7 @@ class _Parser(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
obj_split = sep + basename(object_name)
|
obj_split = sep + basename(object_name)
|
||||||
for module_path, contents in self.modules.items():
|
for module_path, contents in list(self.modules.items()):
|
||||||
if module_path.endswith(obj_split) or module_path == object_name:
|
if module_path.endswith(obj_split) or module_path == object_name:
|
||||||
contents.setdefault(section, 0)
|
contents.setdefault(section, 0)
|
||||||
contents[section] += size
|
contents[section] += size
|
||||||
|
|
|
@ -103,14 +103,14 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Print scrip version
|
# Print scrip version
|
||||||
if opts.version:
|
if opts.version:
|
||||||
print parser.description
|
print(parser.description)
|
||||||
print parser.epilog
|
print(parser.epilog)
|
||||||
print "Version %d.%d"% get_version()
|
print("Version %d.%d"% get_version())
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Print summary / information about automation test status
|
# Print summary / information about automation test status
|
||||||
if opts.test_automation_report:
|
if opts.test_automation_report:
|
||||||
print get_avail_tests_summary_table(platform_filter=opts.general_filter_regex)
|
print(get_avail_tests_summary_table(platform_filter=opts.general_filter_regex))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Print summary / information about automation test status
|
# Print summary / information about automation test status
|
||||||
|
@ -122,15 +122,15 @@ if __name__ == '__main__':
|
||||||
'host_test',
|
'host_test',
|
||||||
'duration',
|
'duration',
|
||||||
'source_dir']
|
'source_dir']
|
||||||
print get_avail_tests_summary_table(cols=test_case_report_cols,
|
print(get_avail_tests_summary_table(cols=test_case_report_cols,
|
||||||
result_summary=False,
|
result_summary=False,
|
||||||
join_delim='\n',
|
join_delim='\n',
|
||||||
platform_filter=opts.general_filter_regex)
|
platform_filter=opts.general_filter_regex))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Only prints matrix of supported toolchains
|
# Only prints matrix of supported toolchains
|
||||||
if opts.supported_toolchains:
|
if opts.supported_toolchains:
|
||||||
print mcu_toolchain_matrix(platform_filter=opts.general_filter_regex)
|
print(mcu_toolchain_matrix(platform_filter=opts.general_filter_regex))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
test_spec = None
|
test_spec = None
|
||||||
|
@ -139,14 +139,14 @@ if __name__ == '__main__':
|
||||||
if hasattr(opts, 'auto_detect') and opts.auto_detect:
|
if hasattr(opts, 'auto_detect') and opts.auto_detect:
|
||||||
# If auto_detect attribute is present, we assume other auto-detection
|
# If auto_detect attribute is present, we assume other auto-detection
|
||||||
# parameters like 'toolchains_filter' are also set.
|
# parameters like 'toolchains_filter' are also set.
|
||||||
print "MBEDLS: Detecting connected mbed-enabled devices... "
|
print("MBEDLS: Detecting connected mbed-enabled devices... ")
|
||||||
|
|
||||||
MUTs = get_autodetected_MUTS_list()
|
MUTs = get_autodetected_MUTS_list()
|
||||||
|
|
||||||
for mut in MUTs.values():
|
for mut in MUTs.values():
|
||||||
print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['mcu_unique'] if 'mcu_unique' in mut else mut['mcu'],
|
print("MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['mcu_unique'] if 'mcu_unique' in mut else mut['mcu'],
|
||||||
mut['port'],
|
mut['port'],
|
||||||
mut['disk'])
|
mut['disk']))
|
||||||
|
|
||||||
# Set up parameters for test specification filter function (we need to set toolchains per target here)
|
# Set up parameters for test specification filter function (we need to set toolchains per target here)
|
||||||
use_default_toolchain = 'default' in opts.toolchains_filter if opts.toolchains_filter is not None else True
|
use_default_toolchain = 'default' in opts.toolchains_filter if opts.toolchains_filter is not None else True
|
||||||
|
@ -179,13 +179,13 @@ if __name__ == '__main__':
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
if opts.verbose_test_configuration_only:
|
if opts.verbose_test_configuration_only:
|
||||||
print "MUTs configuration in %s:" % ('auto-detected' if opts.auto_detect else opts.muts_spec_filename)
|
print("MUTs configuration in %s:" % ('auto-detected' if opts.auto_detect else opts.muts_spec_filename))
|
||||||
if MUTs:
|
if MUTs:
|
||||||
print print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex)
|
print(print_muts_configuration_from_json(MUTs, platform_filter=opts.general_filter_regex))
|
||||||
print
|
print()
|
||||||
print "Test specification in %s:" % ('auto-detected' if opts.auto_detect else opts.test_spec_filename)
|
print("Test specification in %s:" % ('auto-detected' if opts.auto_detect else opts.test_spec_filename))
|
||||||
if test_spec:
|
if test_spec:
|
||||||
print print_test_configuration_from_json(test_spec)
|
print(print_test_configuration_from_json(test_spec))
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
if get_module_avail('mbed_lstools'):
|
if get_module_avail('mbed_lstools'):
|
||||||
|
@ -201,16 +201,16 @@ if __name__ == '__main__':
|
||||||
report_exporter = ReportExporter(ResultExporterType.JUNIT_OPER)
|
report_exporter = ReportExporter(ResultExporterType.JUNIT_OPER)
|
||||||
report_exporter.report_to_file(test_results, opts.report_junit_file_name)
|
report_exporter.report_to_file(test_results, opts.report_junit_file_name)
|
||||||
else:
|
else:
|
||||||
print "Unknown interoperability test scope name: '%s'" % (opts.operability_checks)
|
print("Unknown interoperability test scope name: '%s'" % (opts.operability_checks))
|
||||||
print "Available test scopes: %s" % (','.join(["'%s'" % n for n in test_scope]))
|
print("Available test scopes: %s" % (','.join(["'%s'" % n for n in test_scope])))
|
||||||
|
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# Verbose test specification and MUTs configuration
|
# Verbose test specification and MUTs configuration
|
||||||
if MUTs and opts.verbose:
|
if MUTs and opts.verbose:
|
||||||
print print_muts_configuration_from_json(MUTs)
|
print(print_muts_configuration_from_json(MUTs))
|
||||||
if test_spec and opts.verbose:
|
if test_spec and opts.verbose:
|
||||||
print print_test_configuration_from_json(test_spec)
|
print(print_test_configuration_from_json(test_spec))
|
||||||
|
|
||||||
if opts.only_build_tests:
|
if opts.only_build_tests:
|
||||||
# We are skipping testing phase, and suppress summary
|
# We are skipping testing phase, and suppress summary
|
||||||
|
|
|
@ -312,7 +312,7 @@ def main():
|
||||||
|
|
||||||
# Print memory map summary on screen
|
# Print memory map summary on screen
|
||||||
if build_report:
|
if build_report:
|
||||||
print
|
print()
|
||||||
print(print_build_memory_usage(build_report))
|
print(print_build_memory_usage(build_report))
|
||||||
|
|
||||||
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
||||||
|
|
|
@ -1461,11 +1461,11 @@ def get_avail_tests_summary_table(cols=None, result_summary=True, join_delim=','
|
||||||
def progress_bar(percent_progress, saturation=0):
|
def progress_bar(percent_progress, saturation=0):
|
||||||
""" This function creates progress bar with optional simple saturation mark
|
""" This function creates progress bar with optional simple saturation mark
|
||||||
"""
|
"""
|
||||||
step = int(percent_progress / 2) # Scale by to (scale: 1 - 50)
|
step = percent_progress // 2 # Scale by to (scale: 1 - 50)
|
||||||
str_progress = '#' * step + '.' * int(50 - step)
|
str_progress = '#' * step + '.' * int(50 - step)
|
||||||
c = '!' if str_progress[38] == '.' else '|'
|
c = '!' if str_progress[38] == '.' else '|'
|
||||||
if saturation > 0:
|
if saturation > 0:
|
||||||
saturation = saturation / 2
|
saturation = saturation // 2
|
||||||
str_progress = str_progress[:saturation] + c + str_progress[saturation:]
|
str_progress = str_progress[:saturation] + c + str_progress[saturation:]
|
||||||
return str_progress
|
return str_progress
|
||||||
|
|
||||||
|
@ -1517,7 +1517,7 @@ def singletest_in_cli_mode(single_test):
|
||||||
# Returns True if no build failures of the test projects or their dependencies
|
# Returns True if no build failures of the test projects or their dependencies
|
||||||
return status
|
return status
|
||||||
|
|
||||||
class TestLogger():
|
class TestLogger(object):
|
||||||
""" Super-class for logging and printing ongoing events for test suite pass
|
""" Super-class for logging and printing ongoing events for test suite pass
|
||||||
"""
|
"""
|
||||||
def __init__(self, store_log=True):
|
def __init__(self, store_log=True):
|
||||||
|
|
|
@ -29,7 +29,7 @@ ResultExporterType = construct_enum(HTML='Html_Exporter',
|
||||||
PRINT='Print_Exporter')
|
PRINT='Print_Exporter')
|
||||||
|
|
||||||
|
|
||||||
class ReportExporter():
|
class ReportExporter(object):
|
||||||
""" Class exports extended test result Python data structure to
|
""" Class exports extended test result Python data structure to
|
||||||
different formats like HTML, JUnit XML.
|
different formats like HTML, JUnit XML.
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from past.builtins import cmp
|
||||||
from tools.paths import *
|
from tools.paths import *
|
||||||
from argparse import ArgumentTypeError
|
from argparse import ArgumentTypeError
|
||||||
from tools.utils import columnate
|
from tools.utils import columnate
|
||||||
|
@ -857,7 +858,7 @@ except:
|
||||||
TEST_GROUPS = {}
|
TEST_GROUPS = {}
|
||||||
GROUPS.update(TEST_GROUPS)
|
GROUPS.update(TEST_GROUPS)
|
||||||
|
|
||||||
class Test:
|
class Test(object):
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
#'mcu': None,
|
#'mcu': None,
|
||||||
'description': None,
|
'description': None,
|
||||||
|
|
Loading…
Reference in New Issue