summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2016-04-30 12:40:57 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-06 10:20:03 +0100
commit7dc12110d400caaed8198ecdaeb86a65f2a3d984 (patch)
tree54ad1adb968891394dedbc6acfe98bc9e7de028c
parent39b79efc7e39f677287447a608892790b57e3e00 (diff)
downloadpoky-7dc12110d400caaed8198ecdaeb86a65f2a3d984.tar.gz
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>
-rw-r--r--bitbake/lib/bb/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 3544bbe170..92f1b60206 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -27,6 +27,7 @@ import bb
27import bb.msg 27import bb.msg
28import multiprocessing 28import multiprocessing
29import fcntl 29import fcntl
30import imp
30import subprocess 31import subprocess
31import glob 32import glob
32import fnmatch 33import fnmatch
@@ -1451,3 +1452,23 @@ def export_proxies(d):
1451 exported = True 1452 exported = True
1452 1453
1453 return exported 1454 return exported
1455
1456
1457def load_plugins(logger, plugins, pluginpath):
1458 def load_plugin(name):
1459 logger.debug('Loading plugin %s' % name)
1460 fp, pathname, description = imp.find_module(name, [pluginpath])
1461 try:
1462 return imp.load_module(name, fp, pathname, description)
1463 finally:
1464 if fp:
1465 fp.close()
1466
1467 logger.debug('Loading plugins from %s...' % pluginpath)
1468 for fn in glob.glob(os.path.join(pluginpath, '*.py')):
1469 name = os.path.splitext(os.path.basename(fn))[0]
1470 if name != '__init__':
1471 plugin = load_plugin(name)
1472 if hasattr(plugin, 'plugin_init'):
1473 plugin.plugin_init(plugins)
1474 plugins.append(plugin)