diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 21 |
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 | |||
27 | import bb.msg | 27 | import bb.msg |
28 | import multiprocessing | 28 | import multiprocessing |
29 | import fcntl | 29 | import fcntl |
30 | import imp | ||
30 | import subprocess | 31 | import subprocess |
31 | import glob | 32 | import glob |
32 | import fnmatch | 33 | import 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 | |||
1457 | def 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) | ||