From: Dan Mick Date: Mon, 3 Jun 2013 19:32:14 +0000 (-0700) Subject: ceph: backward-compatibility hack: blank line before JSON output X-Git-Tag: v0.65~136^2^2~25 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fbfdd51a4dd39ddc805cf0d4b49313318bb679fd;p=ceph.git ceph: backward-compatibility hack: blank line before JSON output Many JSON commands (osd dump, et. al.) used to print a status line first before the actual output; this has been fixed, but there are scripts/tools/etc. that expect it. A simple compatibility hack is to output a blank line, which won't confuse properly-written JSON parsers, but will allow the tools-with-workarounds to continue to work. Signed-off-by: Dan Mick --- diff --git a/src/ceph b/src/ceph index 08e2c7482675..c34438ac4d80 100755 --- a/src/ceph +++ b/src/ceph @@ -1451,6 +1451,14 @@ def main(): outf.write(outbuf) outf.close() else: + # hack: old code printed status line before many json outputs + # (osd dump, etc.) that consumers know to ignore. Add blank line + # to satisfy consumers that skip the first line, but not annoy + # consumers that don't. + if parsed_args.output_format and \ + parsed_args.output_format.startswith('json'): + sys.stdout.write('\n'); + sys.stdout.write(outbuf) # this assumes outs never has useful command output, only status