Parcourir la 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 il y a 14 ans
Parent
commit
3954c628c1
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  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))