summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-16 09:27:15 -0500
committerSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-16 09:27:15 -0500
commit1420dbfbb699bbe969228173924bfa92ba7f7ce2 (patch)
treec0c0119f6ac58c3a38d4ac3e5541abcd7181a759
parent79d75b06a1bdae8c5c42026de606ed1787be6030 (diff)
downloadthird_party-func-1420dbfbb699bbe969228173924bfa92ba7f7ce2.tar.gz
third_party-func-1420dbfbb699bbe969228173924bfa92ba7f7ce2.tar.xz
third_party-func-1420dbfbb699bbe969228173924bfa92ba7f7ce2.zip
Updated networktest to be the new way of defining modules and updated func-create-module to add in docstrings.
-rw-r--r--func/minion/modules/networktest.py16
-rwxr-xr-xscripts/func-create-module11
2 files changed, 11 insertions, 16 deletions
diff --git a/func/minion/modules/networktest.py b/func/minion/modules/networktest.py
index e88c169..ed2f3ab 100644
--- a/func/minion/modules/networktest.py
+++ b/func/minion/modules/networktest.py
@@ -9,23 +9,13 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-from modules import func_module
+import func_module
from codes import FuncException
import sub_process
class NetworkTest(func_module.FuncModule):
- def __init__(self):
- self.methods = {
- "ping" : self.ping,
- "netstat" : self.netstat,
- "traceroute" : self.traceroute,
- "dig" : self.dig,
- "isportopen" : self.isportopen,
- }
- func_module.FuncModule.__init__(self)
-
def ping(self, *args):
if '-c' not in args:
raise(FuncException("You must define a count with -c!"))
@@ -58,7 +48,3 @@ class NetworkTest(func_module.FuncModule):
full_cmd = [command] + opts
cmd = sub_process.Popen(full_cmd, stdout=sub_process.PIPE)
return [line for line in cmd.communicate()[0].split('\n')]
-
-
-methods = NetworkTest()
-register_rpc = methods.register_rpc
diff --git a/scripts/func-create-module b/scripts/func-create-module
index 7cbf9eb..cf05449 100755
--- a/scripts/func-create-module
+++ b/scripts/func-create-module
@@ -22,6 +22,15 @@ class %s(func_module.FuncModule):
%s
"""
+METHOD_TEMPLATE = '''\
+ def %s(self):
+ """
+ TODO: Document me ...
+ """
+ pass
+
+'''
+
def populate_template(module_name, desc, methods):
"""
@@ -29,7 +38,7 @@ def populate_template(module_name, desc, methods):
"""
actual_methods = ""
for method in methods:
- actual_methods += " def %s(self):\n pass\n\n" % method
+ actual_methods += METHOD_TEMPLATE % method
return TEMPLATE % (module_name, desc, actual_methods[:-2])