From c77dc9b98dcb8635937caa7089e631e19b7fcb7e Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 25 Oct 2007 15:49:49 -0400 Subject: Make pretty printer be the default print option, and make a new option for raw output that just uses Python print. --- func/overlord/cmd_modules/call.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'func/overlord/cmd_modules') diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py index 48a6598..b3484f6 100644 --- a/func/overlord/cmd_modules/call.py +++ b/func/overlord/cmd_modules/call.py @@ -31,10 +31,13 @@ class Call(client.command.Command): self.parser.add_option("-v", "--verbose", dest="verbose", action="store_true") self.parser.add_option("-x", "--xmlrpc", dest="xmlrpc", + help="output return data in XMLRPC format", action="store_true") - self.parser.add_option("", "--pprint", dest="pprint", + self.parser.add_option("", "--raw", dest="rawprint", + help="output return data using Python print", action="store_true") self.parser.add_option("-j", "--json", dest="json", + help="output return data using JSON", action="store_true") self.parser.add_option("-p", "--port", dest="port", default=DEFAULT_PORT) @@ -55,21 +58,25 @@ class Call(client.command.Command): def format_return(self, data): + """ + The call module supports multiple output return types, the default is pprint. + """ + if self.options.xmlrpc: return xmlrpclib.dumps((data,"")) - if self.options.pprint: - return pprint.pformat(data) - if self.options.json: try: import simplejson return simplejson.dumps(data) except ImportError: - print "json support not found" + print "WARNING: json support not found, install python-simplejson" return data - return data + if self.options.rawprint: + return data + + return pprint.pformat(data) def do(self, args): -- cgit