[bind10-dev] pretty-printing stats (and bindctl results in general)
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Thu Jan 13 08:16:39 UTC 2011
At Wed, 12 Jan 2011 13:33:00 -0800,
Jelte Jansen <jelte at isc.org> wrote:
> to save us from a little bit of task overhead, pretty-printing command
> results (for instance the Stats show output) is quite easy, and a
> trivial fix:
>
> index 0e5b1bd..cb33977 100644
> - --- a/src/bin/bindctl/bindcmd.py
> +++ b/src/bin/bindctl/bindcmd.py
> @@ -625,6 +625,9 @@ class BindCmdInterpreter(Cmd):
> print("send the command to cmd-ctrld")
> reply = self.send_POST(url, cmd.params)
> data = reply.read().decode()
> - - print("received reply:", data)
> + # The reply is a string containing JSON data,
> + # parse it, then prettyprint
> + if data != "" and data != "{}":
> + print(json.dumps(json.loads(data), sort_keys=True, indent=4))
>
> this changes two things; it will no longer print 'empty' results
> (commands that don't actually return any data still result in '{}' being
> printed right now, and map results like Stats show are sorted and nicely
> printed.
Can you show an example?
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list