[CRIU] [PATCH] crit: sort keys in case of --pretty

Andrey Vagin avagin at openvz.org
Fri Jul 3 01:14:20 PDT 2015


It's easier to find a required field

Here is an example of output:
{
    "entries": [
        {
            "dump": {
                "freezing_time": 798,
                "frozen_time": 899318,
                "irmap_resolve": 0,
                "memdump_time": 34747,
                "memwrite_time": 237,
                "pages_scanned": 133338,
                "pages_skipped_parent": 0,
                "pages_written": 54,
            }
        }
    ],
    "magic": "STATS"
}

Cc: Ruslan Kuprieiev <kupruser at gmail.com>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 crit | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/crit b/crit
index 88f3b8e..f5c668a 100755
--- a/crit
+++ b/crit
@@ -19,14 +19,15 @@ def outf(opts):
 
 
 def decode(opts):
-	indent = None
+	kwargs = {}
 	img = pycriu.images.load(inf(opts), opts['pretty'])
 
 	if opts['pretty']:
-		indent = 4
+		kwargs['indent'] = 4
+		kwargs['sort_keys'] = True
 
 	f = outf(opts)
-	json.dump(img, f, indent=indent)
+	json.dump(img, f, **kwargs)
 	if f == sys.stdout:
 		f.write("\n")
 
-- 
2.1.0



More information about the CRIU mailing list