[oe-commits] [bitbake] 01/03: bb.utils: add load_plugins from scriptutils
git at git.openembedded.org
git at git.openembedded.org
Fri May 6 09:20:35 UTC 2016
rpurdie pushed a commit to branch master
in repository bitbake.
commit 99db61bf816d9c735032caa762aae8e6a0803402
Author: Christopher Larson <chris_larson at mentor.com>
AuthorDate: Sat Apr 30 12:40:57 2016 -0700
bb.utils: add load_plugins from scriptutils
Imported as of oe-core 184a256.
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/utils.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 3544bbe..92f1b60 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -27,6 +27,7 @@ import bb
import bb.msg
import multiprocessing
import fcntl
+import imp
import subprocess
import glob
import fnmatch
@@ -1451,3 +1452,23 @@ def export_proxies(d):
exported = True
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)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list