Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Unified Diff: scripts/tools/gzjsondump.py

Issue 1501663002: annotated_run.py: Add LogDog bootstrapping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/slave/unittests/annotated_run_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/tools/gzjsondump.py
diff --git a/scripts/tools/gzjsondump.py b/scripts/tools/gzjsondump.py
new file mode 100755
index 0000000000000000000000000000000000000000..7079ac4df956b3b0a3b523d4b0276fe29c233061
--- /dev/null
+++ b/scripts/tools/gzjsondump.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import base64
+import json
+import os
+import sys
+import zlib
+
+sys.path.insert(0,
+ os.path.join(os.path.dirname(__file__), os.pardir))
+ # (/path/to/build/scripts)
+import common.env
+common.env.Install()
+
+from common import chromium_utils
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-o', '--out', default=sys.stdout,
+ help='Write the output content here. If omitted, output will be written '
+ 'to STDOUT.')
+ def add_value_arg(p):
+ p.add_argument('value', nargs='?',
+ help='The intput content. If omitted, content will be read from STDIN.')
+ subparsers = parser.add_subparsers()
+
+ # encode
+ p = subparsers.add_parser('encode')
+ def encode(value, out):
+ obj = json.loads(value)
+ out.write(chromium_utils.b64_gz_json_encode(obj))
+ p.set_defaults(func=encode)
+ add_value_arg(p)
+
+ # decode
+ p = subparsers.add_parser('decode')
+ def decode(value, out):
+ obj = chromium_utils.convert_gz_json_type(value)
+ json.dump(obj, out, sort_keys=True, separators=(',', ':'))
+ p.set_defaults(func=decode)
+ add_value_arg(p)
+
+ opts = parser.parse_args()
+
+ # Read input value.
+ value = opts.value
+ if not value:
+ value = sys.stdin.read()
+
+ # Generate output.
+ opts.func(value, opts.out)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « scripts/slave/unittests/annotated_run_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698