diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-10-25 15:49:49 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2007-10-25 15:49:49 -0400 |
commit | c77dc9b98dcb8635937caa7089e631e19b7fcb7e (patch) | |
tree | 1067c8a4435e5bcc982a0636ef1ec50983f87901 | |
parent | 8d1b292046848a3cd4201c4cfd531d141ef167ba (diff) | |
download | third_party-func-c77dc9b98dcb8635937caa7089e631e19b7fcb7e.tar.gz third_party-func-c77dc9b98dcb8635937caa7089e631e19b7fcb7e.tar.xz third_party-func-c77dc9b98dcb8635937caa7089e631e19b7fcb7e.zip |
Make pretty printer be the default print option, and make a new option for raw output that just
uses Python print.
-rw-r--r-- | func/overlord/cmd_modules/call.py | 19 |
1 files changed, 13 insertions, 6 deletions
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): |