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

Side by Side 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: Updated, actually works. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
dnj 2016/01/14 22:50:28 I wrote this b/c I am sick of writing one-off scri
iannucci 2016/01/15 04:18:18 k
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import base64
8 import json
9 import os
10 import sys
11 import zlib
12
13 sys.path.insert(0,
14 os.path.join(os.path.dirname(__file__), os.pardir))
15 # (/path/to/build/scripts)
16 import common.env
17 common.env.Install()
18
19 from common import chromium_utils
20
21 def main():
22 parser = argparse.ArgumentParser()
23 parser.add_argument('-o', '--out', default=sys.stdout,
24 help='Write the output content here. If omitted, output will be written '
25 'to STDOUT.')
26 def add_value_arg(p):
27 p.add_argument('value', nargs='?',
28 help='The intput content. If omitted, content will be read from STDIN.')
29 subparsers = parser.add_subparsers()
30
31 # encode
32 p = subparsers.add_parser('encode')
33 def encode(value, out):
34 obj = json.loads(value)
35 out.write(chromium_utils.b64_gz_json_encode(obj))
36 p.set_defaults(func=encode)
37 add_value_arg(p)
38
39 # decode
40 p = subparsers.add_parser('decode')
41 def decode(value, out):
42 obj = chromium_utils.convert_gz_json_type(value)
43 json.dump(obj, out, sort_keys=True, separators=(',', ':'))
44 p.set_defaults(func=decode)
45 add_value_arg(p)
46
47 opts = parser.parse_args()
48
49 # Read input value.
50 value = opts.value
51 if not value:
52 value = sys.stdin.read()
53
54 # Generate output.
55 opts.func(value, opts.out)
56 return 0
57
58
59 if __name__ == '__main__':
60 sys.exit(main())
OLDNEW
« scripts/slave/gce.py ('K') | « 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