blob: b2d7ba328aaf94fa58441e6ebdac2722abb1dcb2 [file] [log] [blame]
# Copyright (c) 2017 Linaro Limited.
# SPDX-License-Identifier: Apache-2.0
import importlib
import logging
from runners.core import ZephyrBinaryRunner, MissingProgram
_logger = logging.getLogger('runners')
def _import_runner_module(runner_name):
except ImportError as ie:
# Runners are supposed to gracefully handle failures when they
# import anything outside of stdlib, but they sometimes do
# not. Catch ImportError to handle this.
_logger.warning(f'The module for runner "{runner_name}" '
f'could not be imported ({ie}). This most likely '
'means it is not handling its dependencies properly. '
'Please report this to the zephyr developers.')
# We import these here to ensure the ZephyrBinaryRunner subclasses are
# defined; otherwise, ZephyrBinaryRunner.get_runners() won't work.
_names = [
# Keep this list sorted by runner name; don't add to the end.
for _name in _names:
def get_runner_cls(runner):
'''Get a runner's class object, given its name.'''
for cls in ZephyrBinaryRunner.get_runners():
if == runner:
return cls
raise ValueError('unknown runner "{}"'.format(runner))
__all__ = ['ZephyrBinaryRunner', 'get_runner_cls']