BIND 10 trac810, updated. e58e69f00b57fbb7bdddfbd43e8b958ea50fd146 [trac810] Plugin loader
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Apr 9 10:02:51 UTC 2011
The branch, trac810 has been updated
via e58e69f00b57fbb7bdddfbd43e8b958ea50fd146 (commit)
from b91c7c259c85f29413e05898e8b74ca011835aa6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e58e69f00b57fbb7bdddfbd43e8b958ea50fd146
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Sat Apr 9 12:02:19 2011 +0200
[trac810] Plugin loader
-----------------------------------------------------------------------
Summary of changes:
src/bin/cfgmgr/b10-cfgmgr.py.in | 23 +++++++++++++++++++-
.../cfgmgr/tests/testdata/plugins/testplugin.py | 2 +-
2 files changed, 23 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in
index d680641..e3f1ca7 100755
--- a/src/bin/cfgmgr/b10-cfgmgr.py.in
+++ b/src/bin/cfgmgr/b10-cfgmgr.py.in
@@ -23,6 +23,8 @@ import isc.util.process
import signal
import os
from optparse import OptionParser
+import glob
+import os.path
isc.util.process.rename()
@@ -66,7 +68,26 @@ def signal_handler(signal, frame):
cm.running = False
def load_plugins(path, cm):
- pass
+ """Load all python files in the given path and treat them as plugins."""
+ # Find the python files
+ plugins = glob.glob(path + os.sep + '*.py')
+ # Search this directory first, but leave the others there for the imports
+ # of the modules
+ sys.path.insert(0, path)
+ try:
+ for plugin in plugins:
+ # Generate the name of the plugin
+ filename = os.path.basename(plugin)
+ name = filename[:-3]
+ # Load it
+ module = __import__(name)
+ # Ask it to provide the spec and checking function
+ (spec, check_func) = module.load()
+ # And insert it into the manager
+ cm.set_virtual_module(spec, check_func)
+ finally:
+ # Restore the search path
+ sys.path = sys.path[1:]
def main():
options = parse_options()
diff --git a/src/bin/cfgmgr/tests/testdata/plugins/testplugin.py b/src/bin/cfgmgr/tests/testdata/plugins/testplugin.py
index 93a6c1d..a50eefe 100644
--- a/src/bin/cfgmgr/tests/testdata/plugins/testplugin.py
+++ b/src/bin/cfgmgr/tests/testdata/plugins/testplugin.py
@@ -23,7 +23,7 @@ class MockSpec:
def get_module_name(self):
return "mock_config_plugin"
-def mock_check_config(config)
+def mock_check_config(config):
"""Mock function to check config. Does nothing, only returns
an "error" string to indicate it's this one."""
return "Mock config plugin"
More information about the bind10-changes
mailing list