[oe-commits] [openembedded-core] 21/24: context.py: Do not mask exceptions needlessly.

git at git.openembedded.org git at git.openembedded.org
Tue Aug 7 11:51:37 UTC 2018


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 4aed2195c8ce7481c0c5f19b72071f90607e81b4
Author: Paulo Neves <ptsneves at gmail.com>
AuthorDate: Mon Aug 6 13:26:58 2018 +0200

    context.py: Do not mask exceptions needlessly.
    
    There were a lot of assumptions in the controller import
    code of context.py which were not true anymore.  These
    assumptions reflected themselves by catching exceptions and
    re-raising them with unhelpful error messages in other parts
    of the code.
    
    This commit does not fix the classes controller classes that
    became broken after the refactor but at least it allows for
    the exceptions to be thrown where the imports fail, thus
    actually showing what exactly went wrong with the import.
    
    An example of such an improvement is that before if the
    controller class failed during it's init contructor the
    controller would just be skipped and the task would just
    complain it could not find the controller.  Now for example,
    if there is a NamerError due to a variable not being
    declared, the user will get that report.
    
    Signed-off-by: Paulo Neves <ptsneves at gmail.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/lib/oeqa/runtime/context.py | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 0294003..a7f3823 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -112,12 +112,9 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
             # XXX: Don't base your targets on this code it will be refactored
             # in the near future.
             # Custom target module loading
-            try:
-                target_modules_path = kwargs.get('target_modules_path', '')
-                controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
-                target = controller(logger, target_ip, server_ip, **kwargs)
-            except ImportError as e:
-                raise TypeError("Failed to import %s from available controller modules" % target_type)
+            target_modules_path = kwargs.get('target_modules_path', '')
+            controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
+            target = controller(logger, target_ip, server_ip, **kwargs)
 
         return target
 
@@ -173,10 +170,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
     def _loadControllerFromModule(target, modulename):
         obj = None
         # import module, allowing it to raise import exception
-        try:
-            module = __import__(modulename, globals(), locals(), [target])
-        except Exception as e:
-            return obj
+        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:

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


More information about the Openembedded-commits mailing list