Francesco Romani has uploaded a new change for review. Change subject: contrib: add simple tool to prettify python dumps ......................................................................
contrib: add simple tool to prettify python dumps We often need to feed log dumps into tests, like API logs. Python doesn't care about formatting, but us humans do. Add a simple tool to reformat the dumps into something human-readable. Change-Id: I3962648db542afb4297e7712c017ffa266c52424 Signed-off-by: Francesco Romani <from...@redhat.com> --- A contrib/refmt 1 file changed, 32 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/60272/1 diff --git a/contrib/refmt b/contrib/refmt new file mode 100644 index 0000000..311c94f --- /dev/null +++ b/contrib/refmt @@ -0,0 +1,32 @@ +#!/usr/bin/python + +# helper script to prettify Vdsm parameter dumps from the logs. +# useful to extract test data. +# This tool is intended to make it easier for humans to read +# the dump. +# +# PLEASE NOTE that this tool modifies the input files *in place*. +# +# The intended workflow is: +# 1. scan the Vdsm logs to fetch the parameter/return type +# dump you need +# 2. copy the dump into a file, let's call it 'param.out' +# 3. beautify the dump with +# /path/to/refmt /path/to/param.out +# 4. inspect the dump and use it as you wish. + +import pprint +import sys + + +def refmt(path): + with open(path, 'rt') as src: + data = src.read() + obj = eval(data) + with open(path, 'wt') as dst: + dst.write(pprint.pformat(obj)) + + +if __name__ == '__main__': + for arg in sys.argv[1:]: + refmt(arg) -- To view, visit https://gerrit.ovirt.org/60272 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3962648db542afb4297e7712c017ffa266c52424 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org