mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
bitbake: bb.utils: add load_plugins from scriptutils
Imported as of oe-core 184a256. (Bitbake rev: 99db61bf816d9c735032caa762aae8e6a0803402) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
39b79efc7e
commit
7dc12110d4
@@ -27,6 +27,7 @@ import bb
|
|||||||
import bb.msg
|
import bb.msg
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import fcntl
|
import fcntl
|
||||||
|
import imp
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
import fnmatch
|
import fnmatch
|
||||||
@@ -1451,3 +1452,23 @@ def export_proxies(d):
|
|||||||
exported = True
|
exported = True
|
||||||
|
|
||||||
return exported
|
return exported
|
||||||
|
|
||||||
|
|
||||||
|
def load_plugins(logger, plugins, pluginpath):
|
||||||
|
def load_plugin(name):
|
||||||
|
logger.debug('Loading plugin %s' % name)
|
||||||
|
fp, pathname, description = imp.find_module(name, [pluginpath])
|
||||||
|
try:
|
||||||
|
return imp.load_module(name, fp, pathname, description)
|
||||||
|
finally:
|
||||||
|
if fp:
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
logger.debug('Loading plugins from %s...' % pluginpath)
|
||||||
|
for fn in glob.glob(os.path.join(pluginpath, '*.py')):
|
||||||
|
name = os.path.splitext(os.path.basename(fn))[0]
|
||||||
|
if name != '__init__':
|
||||||
|
plugin = load_plugin(name)
|
||||||
|
if hasattr(plugin, 'plugin_init'):
|
||||||
|
plugin.plugin_init(plugins)
|
||||||
|
plugins.append(plugin)
|
||||||
|
|||||||
Reference in New Issue
Block a user