summaryrefslogtreecommitdiffstats
path: root/func/overlord
diff options
context:
space:
mode:
authorAdrian Likins <alikins@grimlock.devel.redhat.com>2007-10-08 15:43:06 -0400
committerAdrian Likins <alikins@grimlock.devel.redhat.com>2007-10-08 15:43:06 -0400
commit070d1700b915729421595b83993abc31005355c1 (patch)
tree8fcdf60cca60654429968e21d381ff90355f20c2 /func/overlord
parentacc98aeb6d460720cd05b15795b7239d44f03a11 (diff)
downloadthird_party-func-070d1700b915729421595b83993abc31005355c1.tar.gz
third_party-func-070d1700b915729421595b83993abc31005355c1.tar.xz
third_party-func-070d1700b915729421595b83993abc31005355c1.zip
add a couple alternatice serializers just for kicks
Diffstat (limited to 'func/overlord')
-rw-r--r--func/overlord/cmd_modules/call.py43
1 files changed, 35 insertions, 8 deletions
diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py
index 644930f..07a3aa2 100644
--- a/func/overlord/cmd_modules/call.py
+++ b/func/overlord/cmd_modules/call.py
@@ -1,6 +1,8 @@
#!/usr/bin/python
import optparse
+import pprint
+import xmlrpclib
from func.overlord import command
from func.overlord import client
@@ -12,38 +14,62 @@ class Call(client.command.Command):
useage = "call nodule method name arg1 arg2..."
def addOptions(self):
self.parser.add_option("-v", "--verbose", dest="verbose",
- action="store_true")
+ action="store_true")
+ self.parser.add_option("-x", "--xmlrpc", dest="xmlrpc",
+ action="store_true")
+ self.parser.add_option("", "--pprint", dest="pprint",
+ action="store_true")
+ self.parser.add_option("-j", "--json", dest="json",
+ action="store_true")
self.parser.add_option("-p", "--port", dest="port",
- default=DEFAULT_PORT)
+ default=DEFAULT_PORT)
def handleOptions(self, options):
- print "self.parentCommand", self.parentCommand
-
self.options = options
self.verbose = options.verbose
self.port = options.port
+
# I'm not really a fan of the "module methodname" approach
# but we'll keep it for now -akl
def parse(self, argv):
self.argv = argv
- print "self.argv,", self.argv
-
# FIXME? not sure this is good or bad, but it seems
# wronky... we try to grab the hostnamegoo from the
# args to the parentCommand
self.server_spec = self.argv[0]
return command.Command.parse(self, argv)
+
+
+ def format_return(self, data):
+ if self.options.xmlrpc:
+ return xmlrpclib.dumps((data,""))
+
+ if self.options.pprint:
+ return pprint.pformat(data)
+
+ if self.options.json:
+ print "fffffffffffffffffffffffffffffffffffffffffff"
+ try:
+ import simplejson
+ return simplejson.dumps(data)
+ except ImportError:
+ print "json support not found"
+ return data
+
+ return data
def do(self, args):
# I'm not really a fan of the "module methodname" approach
# but we'll keep it for now -akl
- print "ARGS", args
+ # I kind of feel like we shouldn't be parsing args here, but I'm
+ # not sure what the write place is -al;
+ self.server_spec = args[0]
self.module = args[1]
self.method = args[2]
self.method_args = args[3:]
@@ -55,4 +81,5 @@ class Call(client.command.Command):
# TO DO: add multiplexer support
# probably as a higher level module.
- return client_obj.cli_return(results)
+ # dump the return code stuff atm till we figure out the right place for it
+ return self.format_return(results)