diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2016-08-17 22:31:25 +0300 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2016-08-22 19:43:26 +0300 |
commit | 60f9d69e016b11c468c98ea75ba0a60c44afbbc4 (patch) | |
tree | ecb49581a9e41a37943c22cd9ef3f63451b20ee7 /yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py | |
parent | e18c61205e0234b03697129c20cc69c9b3940efc (diff) | |
download | openbmc-60f9d69e016b11c468c98ea75ba0a60c44afbbc4.tar.xz |
yocto-poky: Move to import-layers subdir
We are going to import additional layers, so create a subdir to
hold all of the layers that we import with git-subtree.
Change-Id: I6f732153a22be8ca663035c518837e3cc5ec0799
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Diffstat (limited to 'yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py')
-rw-r--r-- | yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py b/yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py deleted file mode 100644 index a1b7b1d92..000000000 --- a/yocto-poky/meta/lib/oeqa/controllers/testtargetloader.py +++ /dev/null @@ -1,70 +0,0 @@ -import types -import bb -import os - -# This class is responsible for loading a test target controller -class TestTargetLoader: - - # Search oeqa.controllers module directory for and return a controller - # corresponding to the given target name. - # AttributeError raised if not found. - # ImportError raised if a provided module can not be imported. - def get_controller_module(self, target, bbpath): - controllerslist = self.get_controller_modulenames(bbpath) - bb.note("Available controller modules: %s" % str(controllerslist)) - controller = self.load_controller_from_name(target, controllerslist) - return controller - - # Return a list of all python modules in lib/oeqa/controllers for each - # layer in bbpath - def get_controller_modulenames(self, bbpath): - - controllerslist = [] - - def add_controller_list(path): - if not os.path.exists(os.path.join(path, '__init__.py')): - bb.fatal('Controllers directory %s exists but is missing __init__.py' % path) - files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')]) - for f in files: - module = 'oeqa.controllers.' + f[:-3] - if module not in controllerslist: - controllerslist.append(module) - else: - bb.warn("Duplicate controller module found for %s, only one added. Layers should create unique controller module names" % module) - - for p in bbpath: - controllerpath = os.path.join(p, 'lib', 'oeqa', 'controllers') - bb.debug(2, 'Searching for target controllers in %s' % controllerpath) - if os.path.exists(controllerpath): - add_controller_list(controllerpath) - return controllerslist - - # Search for and return a controller from given target name and - # set of module names. - # Raise AttributeError if not found. - # Raise ImportError if a provided module can not be imported - def load_controller_from_name(self, target, modulenames): - for name in modulenames: - obj = self.load_controller_from_module(target, name) - if obj: - return obj - raise AttributeError("Unable to load {0} from available modules: {1}".format(target, str(modulenames))) - - # Search for and return a controller or None from given module name - def load_controller_from_module(self, target, modulename): - obj = None - # import module, allowing it to raise import exception - module = __import__(modulename, globals(), locals(), [target]) - # look for target class in the module, catching any exceptions as it - # is valid that a module may not have the target class. - try: - obj = getattr(module, target) - if obj: - from oeqa.targetcontrol import BaseTarget - if (not isinstance(obj, (type, types.ClassType))): - bb.warn("Target {0} found, but not of type Class".format(target)) - if( not issubclass(obj, BaseTarget)): - bb.warn("Target {0} found, but subclass is not BaseTarget".format(target)) - except: - obj = None - return obj |