mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 09:49:35 +02:00
oeqa/runtime: load modules using importlib
Instead of using __import__() which is low-level and discouraged, use importlib. (From OE-Core rev: 9f501d22eab5dbd565f3f5783f4f484a6d1f70a2) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
676757f187
commit
c7d6f9965e
@@ -175,16 +175,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
|
|||||||
# Search for and return a controller or None from given module name
|
# Search for and return a controller or None from given module name
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _loadControllerFromModule(target, modulename):
|
def _loadControllerFromModule(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:
|
try:
|
||||||
obj = getattr(module, target)
|
import importlib
|
||||||
except:
|
module = importlib.import_module(modulename)
|
||||||
obj = None
|
return getattr(module, target)
|
||||||
return obj
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def readPackagesManifest(manifest):
|
def readPackagesManifest(manifest):
|
||||||
|
|||||||
Reference in New Issue
Block a user