Browse Source

pretty-print command results

Most obvious change is for the command "Stats show", where the blob of stats data is now printed ina more readable fashion.
Also removed the print of 'send the command' line, and empty results are not printed at all
Jelte Jansen 14 years ago
parent
commit
3954c628c1
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/bin/bindctl/bindcmd.py

+ 4 - 2
src/bin/bindctl/bindcmd.py

@@ -622,9 +622,11 @@ class BindCmdInterpreter(Cmd):
         if (len(cmd.params) != 0):
             cmd_params = json.dumps(cmd.params)
 
-        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))