[CRIU] [PATCH] crit: sort keys in case of --pretty
Andrey Vagin
avagin at openvz.org
Fri Jul 3 01:34:17 PDT 2015
2015-07-03 11:22 GMT+03:00 Ruslan Kuprieiev <kupruser at gmail.com>:
> On 07/03/2015 11:14 AM, Andrey Vagin wrote:
>>
>> 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)
>
>
> This conflicts with collections.OrderedDict, which makes fields order
> to be just the same as in .proto file, which is a lot better than just an
> alphabetic order.
I forgot to rebase my repo. You are right. We need to drop this patch.
>
>
>> if f == sys.stdout:
>> f.write("\n")
>>
>
>
More information about the CRIU
mailing list