From 23c9c26d270ff766133e7aeebffc99a35633ef41 Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Tue, 15 Jan 2008 17:42:05 -0500 Subject: Simplify our modules by auto-detecting them and registering their handlers - Auto-detect and load all FuncModules. This obsoletes the need to have our modules define a register_rpc method. - Use introspection in our FuncModule to auto-register all method handlers that do not being with an underscore. This obsoletes the need to hardcode methods in our modules. - Remove all __init__ methods from our modules, along with register_rpc - Modify the func-create-module script to reflect these changes. Note that doing 'from modules import func_module' is no longer supported in our modules, do to some interesting path issues with our auto-detection code. Supported methods are now: 'import func_module' or 'from func.minion.modules import func_module' --- func/minion/modules/command.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'func/minion/modules/command.py') diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index 3329927..9b93de5 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -13,19 +13,11 @@ Abitrary command execution module for func. """ -from modules import func_module - +import func_module import sub_process class Command(func_module.FuncModule): - def __init__(self): - self.methods = { - "run" : self.run, - "exists" : self.exists, - } - func_module.FuncModule.__init__(self) - def run(self, command): """ Runs a command, returning the return code, stdout, and stderr as a tuple. @@ -46,7 +38,3 @@ class Command(func_module.FuncModule): if os.access(command, os.X_OK): return True return False - - -methods = Command() -register_rpc = methods.register_rpc \ No newline at end of file -- cgit From 0556acbe5ed39c36d38b99dd3ae455691964a1e1 Mon Sep 17 00:00:00 2001 From: Steve 'Ashcrow' Milner Date: Wed, 16 Jan 2008 10:23:29 -0500 Subject: added in the desc/version/api items in the modules. --- func/minion/modules/command.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'func/minion/modules/command.py') diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index 9b93de5..cc463cf 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -18,6 +18,10 @@ import sub_process class Command(func_module.FuncModule): + version = "0.0.1" + api_version = "0.0.1" + description = "Works with shell commands." + def run(self, command): """ Runs a command, returning the return code, stdout, and stderr as a tuple. -- cgit