[oe-commits] [openembedded-core] 15/28: oeqa/runtime/context.py: ignore more files when loading controllers

git at git.openembedded.org git at git.openembedded.org
Tue Oct 22 12:58:54 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit b22a0d333df07ab3a11f7c3fabf049afb50a16b0
Author: André Draszik <git at andred.net>
AuthorDate: Mon Oct 21 11:30:06 2019 +0100

    oeqa/runtime/context.py: ignore more files when loading controllers
    
    When loading controllers as (external) modules, the code currently
    tries to load all files ending with .py. This is a problem when
    during development using an editor that creates a lock-file
    in the same directory as the .py file, as the lock file is
    typically called '.#xxxx.py'.
    Python will try to load the lock file and fail miserably with
    an exception:
    
        The stack trace of python calls that resulted in this exception/failure was:
        File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
             0001:
         *** 0002:do_testimage(d)
             0003:
        File: 'poky/meta/classes/testimage.bbclass', lineno: 114, function: do_testimage
             0110:    netstat -an
             0111:}
             0112:
             0113:python do_testimage() {
         *** 0114:    testimage_main(d)
             0115:}
             0116:
             0117:addtask testimage
             0118:do_testimage[nostamp] = "1"
        File: 'poky/meta/classes/testimage.bbclass', lineno: 294, function: testimage_main
             0290:
             0291:    # the robot dance
             0292:    target = OERuntimeTestContextExecutor.getTarget(
             0293:        d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"),
         *** 0294:        d.getVar("TEST_SERVER_IP"), **target_kwargs)
             0295:
             0296:    # test context
             0297:    tc = OERuntimeTestContext(td, logger, target, host_dumper,
             0298:                              image_packages, extract_dir)
        File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 116, function: getTarget
             0112:            # XXX: Don't base your targets on this code it will be refactored
             0113:            # in the near future.
             0114:            # Custom target module loading
             0115:            target_modules_path = kwargs.get('target_modules_path', '')
         *** 0116:            controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
             0117:            target = controller(logger, target_ip, server_ip, **kwargs)
             0118:
             0119:        return target
             0120:
        File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 128, function: getControllerModule
             0124:    # ImportError raised if a provided module can not be imported.
             0125:    @staticmethod
             0126:    def getControllerModule(target, target_modules_path):
             0127:        controllerslist = OERuntimeTestContextExecutor._getControllerModulenames(target_modules_path)
         *** 0128:        controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist)
             0129:        return controller
             0130:
             0131:    # Return a list of all python modules in lib/oeqa/controllers for each
             0132:    # layer in bbpath
        File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 163, function: _loadControllerFromName
             0159:    # Raise ImportError if a provided module can not be imported
             0160:    @staticmethod
             0161:    def _loadControllerFromName(target, modulenames):
             0162:        for name in modulenames:
         *** 0163:            obj = OERuntimeTestContextExecutor._loadControllerFromModule(target, name)
             0164:            if obj:
             0165:                return obj
             0166:        raise AttributeError("Unable to load {0} from available modules: {1}".format(target, str(modulenames)))
             0167:
        File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 173, function: _loadControllerFromModule
             0169:    @staticmethod
             0170:    def _loadControllerFromModule(target, modulename):
             0171:        obj = None
             0172:        # import module, allowing it to raise import exception
         *** 0173:        module = __import__(modulename, globals(), locals(), [target])
             0174:        # look for target class in the module, catching any exceptions as it
             0175:        # is valid that a module may not have the target class.
             0176:        try:
             0177:            obj = getattr(module, target)
        Exception: ImportError: No module named 'oeqa.controllers.'
    
    Simply ignore those when collecting the list of files to try
    to load.
    
    Signed-off-by: André Draszik <git at andred.net>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oeqa/runtime/context.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 77d58ee..ef738a3 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -138,7 +138,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
         def add_controller_list(path):
             if not os.path.exists(os.path.join(path, '__init__.py')):
                 raise OSError('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('_')])
+            files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_') and not f.startswith('.#')])
             for f in files:
                 module = 'oeqa.controllers.' + f[:-3]
                 if module not in controllerslist:

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list